summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-04-07 12:25:40 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-04-07 12:31:03 (GMT)
commitacf57d3f4547272b766b740666ed16284e4ee608 (patch)
tree513d1d46f97c12056e4df4e88c8fd01e63528035 /src
parent054950602a6675d01a9815a567b69157ee8ceff6 (diff)
downloadQt-acf57d3f4547272b766b740666ed16284e4ee608.zip
Qt-acf57d3f4547272b766b740666ed16284e4ee608.tar.gz
Qt-acf57d3f4547272b766b740666ed16284e4ee608.tar.bz2
Carbon: problems closing down native applications
When Qt is used as a plugin, Qt always eats the quit event in the application event handler. This patch makes sure we let the event through in that case. And also that we don't catch the following quit apple event. The whole buisiness of quitting down the native application is not the responsibility of Qt when used as a plugin. Reviewed-by: prasanth
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qapplication_mac.mm43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 28072fc..321492d 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1221,7 +1221,7 @@ void qt_init(QApplicationPrivate *priv, int)
}
#endif
- if (!app_proc_ae_handlerUPP) {
+ if (!app_proc_ae_handlerUPP && !QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor);
for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) {
// Install apple event handler, but avoid overwriting an already
@@ -2446,25 +2446,30 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
}
if(!handled_event) {
if(cmd.commandID == kHICommandQuit) {
- handled_event = true;
- HiliteMenu(0);
- bool handle_quit = true;
- if(QApplicationPrivate::modalState()) {
- int visible = 0;
- const QWidgetList tlws = QApplication::topLevelWidgets();
- for(int i = 0; i < tlws.size(); ++i) {
- if(tlws.at(i)->isVisible())
- ++visible;
+ // Quitting the application is not Qt's responsibility if
+ // used in a plugin or just embedded into a native application.
+ // In that case, let the event pass down to the native apps event handler.
+ if (!QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
+ handled_event = true;
+ HiliteMenu(0);
+ bool handle_quit = true;
+ if(QApplicationPrivate::modalState()) {
+ int visible = 0;
+ const QWidgetList tlws = QApplication::topLevelWidgets();
+ for(int i = 0; i < tlws.size(); ++i) {
+ if(tlws.at(i)->isVisible())
+ ++visible;
+ }
+ handle_quit = (visible <= 1);
+ }
+ if(handle_quit) {
+ QCloseEvent ev;
+ QApplication::sendSpontaneousEvent(app, &ev);
+ if(ev.isAccepted())
+ app->quit();
+ } else {
+ QApplication::beep();
}
- handle_quit = (visible <= 1);
- }
- if(handle_quit) {
- QCloseEvent ev;
- QApplication::sendSpontaneousEvent(app, &ev);
- if(ev.isAccepted())
- app->quit();
- } else {
- QApplication::beep();
}
} else if(cmd.commandID == kHICommandSelectWindow) {
if((GetCurrentKeyModifiers() & cmdKey))