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>
bb10
Tor Arne Vestbø 2021-10-19 12:30:35 +02:00
parent 132ed5eb51
commit 4ea32eaad0
3 changed files with 14 additions and 0 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}