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
Pick-to: 6.5 6.5.0
Change-Id: I63fba0a092018bb19edeef78c06587455d752235
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Tor Arne Vestbø 2023-03-06 10:57:27 +01:00
parent 4d09152344
commit 4e59a5252c
1 changed files with 5 additions and 0 deletions

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();