summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-10-19 12:30:35 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-10-20 21:17:08 +0200
commit4ea32eaad0138ee49484780a34bc8d2364c096cb (patch)
tree463fca7847d7724b32ac42f97c796acd51714ec7
parent132ed5eb51c63bd34a5d96fc29e8e3868e5ce5a5 (diff)
macOS: Wake up event dispatcher after running modal dialog helpers
The root event loop may have been exited, so we need to ensure the event dispatcher is woken up so it can evaluate whether it should continue or not. For most applications this happens automatically when e.g. the user moves their mouse or press a key, but for tests this may not be the case, and the test will stall and never exit its event loop. Pick-to: 6.2 Change-Id: Ic241e3f1045481c34150289ff711b921addb18e4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm5
3 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index 4e8b87c41c..b21b7c2cc9 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -236,6 +236,11 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
[NSApp runModalForWindow:mColorPanel];
mDialogIsExecuting = false;
+
+ // Wake up the event dispatcher so it can check whether the
+ // current event loop should continue spinning or not.
+ QCoreApplication::eventDispatcher()->wakeUp();
+
return (mResultCode == NSModalResponseOK);
}
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index e84d50d729..8bd649e461 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -206,6 +206,10 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
auto result = [m_panel runModal];
m_helper->panelClosed(result);
+
+ // Wake up the event dispatcher so it can check whether the
+ // current event loop should continue spinning or not.
+ QCoreApplication::eventDispatcher()->wakeUp();
}
- (void)closePanel
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 4fa8ea2721..355d658242 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -218,6 +218,11 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
[NSApp runModalForWindow:mFontPanel];
mDialogIsExecuting = false;
+
+ // Wake up the event dispatcher so it can check whether the
+ // current event loop should continue spinning or not.
+ QCoreApplication::eventDispatcher()->wakeUp();
+
return (mResultCode == NSModalResponseOK);
}