From b837e7024afcf4597082998f97dcc663c13c6380 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 4 Mar 2010 15:45:33 +0200 Subject: 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 --- src/gui/widgets/qmenu_symbian.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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)); } -- cgit v0.12