summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2010-03-04 13:45:33 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2010-03-05 06:42:51 (GMT)
commitb837e7024afcf4597082998f97dcc663c13c6380 (patch)
treedc9a4e2350be0b42b38832df796dafde7259b5ea /src/gui/widgets
parent729d71641ef921f345debac33b52669f9e639c28 (diff)
downloadQt-b837e7024afcf4597082998f97dcc663c13c6380.zip
Qt-b837e7024afcf4597082998f97dcc663c13c6380.tar.gz
Qt-b837e7024afcf4597082998f97dcc663c13c6380.tar.bz2
Fixed crash in Symbian when having empty QMenu in menubar.
Typically cascade menus in Symbian/S60 are created from resources. When cascade menus are defined in resources the RestoreMenuL is responsible for instantiating the cascade menu item array and items. In Qt for Symbian the menus need to be created dynamically from QActions, that's why RestoreMenuL is reimplemeted in Qt for Symbian to dynamically init the menu pane content. Adding a first dynamic item to cascase menu pane creates the CEikMenuPane internal item array. In case where empty QMenu was added to QMenubar, the item array for cascade menupane was never constructed. Then later on CEikMenuPane code assumes that item array exist. To avoid access violation crash we now create the item array manually when building submenu. Task-number: QTBUG-4897 Reviewed-by: Jason Barron
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index eae97a6..e46688c 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -256,6 +256,14 @@ void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id)
{
SymbianMenuItem* menu = qt_symbian_find_menu(id, symbianMenus);
if (menu) {
+ // Normally first AddMenuItemL call for menuPane will create the item array.
+ // However if we don't have any items, we still need the item array. Otherwise
+ // menupane will crash. That's why we create item array here manually, and
+ // AddMenuItemL will then use the existing array.
+ CEikMenuPane::CItemArray* itemArray = q_check_ptr(new CEikMenuPane::CItemArray);
+ menuPane->SetItemArray(itemArray);
+ menuPane->SetItemArrayOwnedExternally(EFalse);
+
for (int i = 0; i < menu->children.count(); ++i)
QT_TRAP_THROWING(menuPane->AddMenuItemL(menu->children.at(i)->menuItemData));
}