macOS: Use non-native app modal message box from nested event loops

The NSAlert does not stay open when ran from a nested event loop,
so we need to fall back to the cross platform dialog. The window
modal dialog does not have this issue.

Fixes: QTBUG-111524
Change-Id: I63fba0a092018bb19edeef78c06587455d752235
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 4e59a5252c11738ce4849032a5aa2a23f97a18ed)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-03-06 10:57:27 +01:00 committed by Qt Cherry-pick Bot
parent 556a56104e
commit 805f40924e

View File

@ -80,6 +80,11 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w
if (!options())
return false;
if (windowModality == Qt::ApplicationModal && QThread::currentThread()->loopLevel() > 1) {
qCWarning(lcQpaDialogs, "Cannot use native application modal dialog from nested event loop");
return false;
}
Q_ASSERT(!m_alert);
m_alert = [NSAlert new];
m_alert.window.title = options()->windowTitle().toNSString();