summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-01-27 12:18:16 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-01-27 12:20:34 (GMT)
commit9a2a6531c91d63ad55f65ad6a2b0fdaf7d739bfe (patch)
treec0ea4dba8c1054f1a5d36865ea72cba54fdea1bb /src/gui/widgets
parentb8d29f8ee076beee45cb45e8dfca8f4706d11ebd (diff)
downloadQt-9a2a6531c91d63ad55f65ad6a2b0fdaf7d739bfe.zip
Qt-9a2a6531c91d63ad55f65ad6a2b0fdaf7d739bfe.tar.gz
Qt-9a2a6531c91d63ad55f65ad6a2b0fdaf7d739bfe.tar.bz2
Carbon: deleting a QMenu while it's open will cause a crash
This patch closes the menu bar if it's open when it gets destroyed Task-number: QTBUG-6597 Reviewed-by: cduclos
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qmenu_mac.mm32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index 31bda9a..7e4bbb5 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -175,6 +175,22 @@ static quint32 constructModifierMask(quint32 accel_key)
return ret;
}
+static void cancelAllMenuTracking()
+{
+#ifdef QT_MAC_USE_COCOA
+ QMacCocoaAutoReleasePool pool;
+ NSMenu *mainMenu = [NSApp mainMenu];
+ [mainMenu cancelTracking];
+ for (NSMenuItem *item in [mainMenu itemArray]) {
+ if ([item submenu]) {
+ [[item submenu] cancelTracking];
+ }
+ }
+#else
+ CancelMenuTracking(AcquireRootMenu(), true, 0);
+#endif
+}
+
static bool actualMenuItemVisibility(const QMenuBarPrivate::QMacMenuBarPrivate *mbp,
const QMacMenuAction *action)
{
@@ -1833,6 +1849,8 @@ void QMenuBarPrivate::macDestroyMenuBar()
#ifdef QT_MAC_USE_COCOA
QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
[loader removeActionsFromAppMenu];
+#else
+ cancelAllMenuTracking();
#endif
extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
qt_event_request_menubarupdate();
@@ -1937,20 +1955,6 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget)
return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget);
}
-static void cancelAllMenuTracking()
-{
-#ifdef QT_MAC_USE_COCOA
- QMacCocoaAutoReleasePool pool;
- NSMenu *mainMenu = [NSApp mainMenu];
- [mainMenu cancelTracking];
- for (NSMenuItem *item in [mainMenu itemArray]) {
- if ([item submenu]) {
- [[item submenu] cancelTracking];
- }
- }
-#endif
-}
-
/*!
\internal