Cocoa: fix modal native dialogs with ongoing modal sessions
authorTeemu Katajisto <teemu.katajisto@digia.com>
Thu, 29 Nov 2012 10:46:23 +0000 (12:46 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 1 Dec 2012 07:29:33 +0000 (08:29 +0100)
Commit 26db7de13d5885067844532b5a5814181a0ddf16 introduced the
modal session cleanup for Cocoa print dialog before running the
modal event loop for the dialog. Add the same cleanup for Cocoa
file, font and color dialog helpers.

Task-number: QTBUG-28146

Change-Id: Ifeb7c82566db35f0c6654be7762e9aaffbafb900
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm

index 389ba35..1deb92c 100644 (file)
@@ -282,6 +282,10 @@ static NSButton *macCreateButton(const char *text, NSView *superview)
     mDialogIsExecuting = true;
     [mColorPanel setDelegate:self];
     [mColorPanel setContinuous:YES];
+    // 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.
+    qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
     [NSApp runModalForWindow:mColorPanel];
     return (mResultCode == NSOKButton);
 }
index 682ef48..f9122f5 100644 (file)
@@ -248,6 +248,11 @@ static QString strippedText(QString s)
 
     [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())]
                                            : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]];
+
+    // 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.
+    qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
     mReturnCode = [mSavePanel runModal];
 
     QAbstractEventDispatcher::instance()->interrupt();
index ad93310..5ccd019 100644 (file)
@@ -301,6 +301,10 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
 {
     mDialogIsExecuting = true;
     [mFontPanel setDelegate:self];
+    // 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.
+    qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
     [NSApp runModalForWindow:mFontPanel];
     return (mResultCode == NSOKButton);
 }