diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-01-27 11:34:55 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-01-27 11:37:12 (GMT) |
commit | b8d29f8ee076beee45cb45e8dfca8f4706d11ebd (patch) | |
tree | 84e6dbdba68a93ab3dded03e2f51138b4ac43ddd | |
parent | 44e3b8862cb0927637d841d276850fbac1681745 (diff) | |
download | Qt-b8d29f8ee076beee45cb45e8dfca8f4706d11ebd.zip Qt-b8d29f8ee076beee45cb45e8dfca8f4706d11ebd.tar.gz Qt-b8d29f8ee076beee45cb45e8dfca8f4706d11ebd.tar.bz2 |
Cocoa: qaccessibility test crashes
The reason is that the test first creates a menu bar with an exit item
The exit item gets merged into the appmenu (together with a QAction)
Then we destroy the menu bar, but leave the exit item in the appmenu untouched.
Then we create a new menubar _without_ an exit item
macUpdateMenubar will then, at one point, try to access the old exit item's
QAction, wich is destroyed a long time ago; crash!
This patch will make sure we clear out all actions in the menu bars appmenu
when the menubar gets destroyed.
Reviewed-by: Prasanth
-rw-r--r-- | src/gui/kernel/qcocoamenuloader_mac.mm | 6 | ||||
-rw-r--r-- | src/gui/kernel/qcocoamenuloader_mac_p.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/qmenu_mac.mm | 4 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm index 9f90cec..18b3772 100644 --- a/src/gui/kernel/qcocoamenuloader_mac.mm +++ b/src/gui/kernel/qcocoamenuloader_mac.mm @@ -110,6 +110,12 @@ QT_USE_NAMESPACE } } +- (void)removeActionsFromAppMenu +{ + for (NSMenuItem *item in [appMenu itemArray]) + [item setTag:nil]; +} + - (void)dealloc { [lastAppSpecificItem release]; diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/gui/kernel/qcocoamenuloader_mac_p.h index 432a7a6..81c136e 100644 --- a/src/gui/kernel/qcocoamenuloader_mac_p.h +++ b/src/gui/kernel/qcocoamenuloader_mac_p.h @@ -70,6 +70,7 @@ } - (void)ensureAppMenuInMenu:(NSMenu *)menu; +- (void)removeActionsFromAppMenu; - (NSMenu *)applicationMenu; - (NSMenu *)menu; - (NSMenuItem *)quitMenuItem; diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index cd7f9bd..31bda9a 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1830,6 +1830,10 @@ void QMenuBarPrivate::macDestroyMenuBar() mac_menubar = 0; if (qt_mac_current_menubar.qmenubar == q) { +#ifdef QT_MAC_USE_COCOA + QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + [loader removeActionsFromAppMenu]; +#endif extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp qt_event_request_menubarupdate(); } |