summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2012-10-25 15:28:07 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-14 08:37:50 +0100
commit26db7de13d5885067844532b5a5814181a0ddf16 (patch)
tree859a521ef2c6987e0ea3934035441c1cba98ad5b
parentac9b853242f652dac53aeec561f24ff46d2eae3e (diff)
Cocoa: QPrintDialog does not show/closes down immediatly
This happends if an event loop recursion ends before the native print dialog gets executed (in the same scope). The reason is that the event dispatcher gets interrupted as the first recursion ends. And (because of the big difference between how AppKit implements modal windows compared to Qt) this sets a flag in the dispatcher that gets handled on the next callback to QCocoaEventDispatcher::processPostedEvents. This will tell the dispatcher to break out of the current modal session. But since it cannot detect that an alien (native) session is now running, it closes down that session by accident instead. While code can be written in the event dispatcher to detect this problem, it ends up more clean to just work around the problem from the native dialogs instead. This to avoid making the dispatcher more complex than it already is. Native dialogs is a bit messy already, and the work-arounds needed should be isolated inside those components, and not inside the dispatcher. Change-Id: Ibfde9db4c98401562e7628da1db18d6bed619245 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
index ddbe0d0f2e..dc940d5d6d 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_mac.mm
@@ -192,6 +192,11 @@ void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
[printPanel retain];
[printPanel setOptions:macOptions];
+ // Call processEvents in case the event dispatcher has been interrupted, and needs to do
+ // cleanup of modal sessions. Do this before showing the native dialog, otherwise it will
+ // close down during the cleanup (QTBUG-17913):
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents, QEventLoop::ExcludeSocketNotifiers);
+
QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate) alloc] init];
if (modality == Qt::ApplicationModal) {
int rval = [printPanel runModalWithPrintInfo:printInfo];