From 4d786b6961f23af6edccf75c6b41267285fefcda Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 7 Jan 2010 10:38:52 +0100 Subject: Cocoa: problems quitting application when not using qApp::exec This problem has been around before. At that time it had to do with what part of the application received the kEAQuit apple event. In Qt-4.7 we ensure that NSApplication gets run at least once before we do any other event processing in Qt. That way the menu bar gets fully initialized. The backside of the coin is that NSApplication will not let the quit menu send a terminate action to the menu nibs file owner (qmenuloader_mac.mm) when a modal window is showing on screen. This is normally expected behaviour, but in Qt we allow the user to quit when just a single window/dialog is showing on screen. This fix remaps the quit items target from files owner to first responder. That way we can catch the terminate at the window/responder beeing that, and terminate as needed. Task-number: QTBUG-7197 Reviewed-by: Prasanth --- src/gui/kernel/kernel.pri | 1 + src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 7 +++++++ src/gui/mac/qt_menu.nib/classes.nib | 16 ++++++++-------- src/gui/mac/qt_menu.nib/info.nib | 4 ++-- src/gui/mac/qt_menu.nib/keyedobjects.nib | Bin 5567 -> 5560 bytes 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index f2bd288..30cb043 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -201,6 +201,7 @@ embedded { OBJECTIVE_HEADERS += \ qcocoawindow_mac_p.h \ + qcocoapanel_mac_p.h \ qcocoawindowdelegate_mac_p.h \ qcocoaview_mac_p.h \ qcocoaapplication_mac_p.h \ diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 7661b89..31d81d9 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -160,6 +160,13 @@ QT_END_NAMESPACE qt_dispatchTabletProximityEvent(tabletEvent); } +- (void)terminate:(id)sender +{ + // This function is called from the quit item in the + // menubar, when this window is the first responder + [NSApp terminate:sender]; +} + - (void)sendEvent:(NSEvent *)event { QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; diff --git a/src/gui/mac/qt_menu.nib/classes.nib b/src/gui/mac/qt_menu.nib/classes.nib index fed50a3..0031e0e 100644 --- a/src/gui/mac/qt_menu.nib/classes.nib +++ b/src/gui/mac/qt_menu.nib/classes.nib @@ -5,14 +5,6 @@ IBClasses - CLASS - FirstResponder - LANGUAGE - ObjC - SUPERCLASS - NSObject - - ACTIONS hide @@ -52,6 +44,14 @@ SUPERCLASS NSResponder + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + IBVersion 1 diff --git a/src/gui/mac/qt_menu.nib/info.nib b/src/gui/mac/qt_menu.nib/info.nib index 768cb8b..02e5cca 100644 --- a/src/gui/mac/qt_menu.nib/info.nib +++ b/src/gui/mac/qt_menu.nib/info.nib @@ -3,7 +3,7 @@ IBFramework Version - 670 + 672 IBOldestOS 5 IBOpenObjects @@ -11,7 +11,7 @@ 57 IBSystem Version - 9G55 + 9L31a targetFramework IBCocoaFramework diff --git a/src/gui/mac/qt_menu.nib/keyedobjects.nib b/src/gui/mac/qt_menu.nib/keyedobjects.nib index 18a6648..3edb0ed 100644 Binary files a/src/gui/mac/qt_menu.nib/keyedobjects.nib and b/src/gui/mac/qt_menu.nib/keyedobjects.nib differ -- cgit v0.12