summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication_mac.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-08-11 14:02:27 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-08-14 10:47:47 (GMT)
commitdc2070d82c3d3cd972a52df680c6df9d2989f3e4 (patch)
treebc4a905853ece743966427a41ccf04b9374729c3 /src/gui/kernel/qapplication_mac.mm
parent433ae0c05079f09293667e495bdb3583616cec6c (diff)
downloadQt-dc2070d82c3d3cd972a52df680c6df9d2989f3e4.zip
Qt-dc2070d82c3d3cd972a52df680c6df9d2989f3e4.tar.gz
Qt-dc2070d82c3d3cd972a52df680c6df9d2989f3e4.tar.bz2
Cocoa: Fix several issues with the event dispatcher
Autotest: qcoreapplication, qapplication, qtimer qwidget_window, qwidget Issue 1: stacking order of modal windows was not working correctly. With this patch, we remove the need for rebuilding modal sessions all the time, and when we do, we rebuild them all in the correct order. Issue 2: When running the event processor manually (that is, just calling processEvents in a loop), we sometimes spendt 100% cpu if a window was pending to become modal. The reason was that we need to keep reposting the QCocoaRequestModal event until we could block the calling thread (that is, one of the exec flags was given to processEvents). With this patch, the need for posting QCocoaRequestModal is completly removed in favor of an 'interrupt' approach instead. Issue 3: If using Qt as a plugin, or just add widget to a native cocoa application, it would often lead to closing down the application. The reason is that the event dispatcher needs to restart [NSApp run] now and then. But this approach fails if Qt was not the code that started [NSApp run] in the first place. This patch removes the need to restart NSApp in this situation, at the cost of modal windows not beeing modal if Qt is not spinning the event dispatcher. Normal QDialog::exec etc will always work.
Diffstat (limited to 'src/gui/kernel/qapplication_mac.mm')
-rw-r--r--src/gui/kernel/qapplication_mac.mm26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 5b503b3..0c17892 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1409,13 +1409,8 @@ void QApplicationPrivate::enterModal_sys(QWidget *widget)
qt_button_down = 0;
#ifdef QT_MAC_USE_COCOA
- if (!qt_mac_is_macsheet(widget)) {
- // Add a new, empty (null), NSModalSession to the stack.
- // The next time we spin the event dispatcher, it will
- // check the stack, and recurse into a modal session for it:
- QCocoaModalSessionInfo info = {widget, 0};
- QEventDispatcherMacPrivate::cocoaModalSessionStack.push(info);
- }
+ if (!qt_mac_is_macsheet(widget))
+ QEventDispatcherMacPrivate::beginModalSession(widget);
#endif
}
@@ -1441,7 +1436,7 @@ void QApplicationPrivate::leaveModal_sys(QWidget *widget)
}
#ifdef QT_MAC_USE_COCOA
if (!qt_mac_is_macsheet(widget))
- QEventDispatcherMacPrivate::rebuildModalSessionStack(true);
+ QEventDispatcherMacPrivate::endModalSession(widget);
#endif
}
#ifdef DEBUG_MODAL_EVENTS
@@ -1452,21 +1447,6 @@ void QApplicationPrivate::leaveModal_sys(QWidget *widget)
qt_event_request_menubarupdate();
}
-#if defined(QT_MAC_USE_COCOA)
-void QApplicationPrivate::_q_runAppModalWindow()
-{
- if (QEventDispatcherMacPrivate::blockCocoaRequestModal) {
- // Just postpone the event until the event dispatcher tells
- // us (by releasing the block) that it is OK to recurse into
- // a new event loop for our non-execing modal window:
- qApp->postEvent(qApp, new QEvent(QEvent::CocoaRequestModal));
- } else {
- // Recurse into a new event loop for the current app modal window:
- threadData->eventDispatcher->processEvents(QEventLoop::DialogExec);
- }
-}
-#endif
-
QWidget *QApplicationPrivate::tryModalHelper_sys(QWidget *top)
{
#ifndef QT_MAC_USE_COCOA