Prevent multiple MessageBoxes on Windows on GL context fail

There seems to be a chance of recursion according to real world
reports when on Windows we use MessageBox(). Prevent this.

Task-number: QTBUG-102846
Change-Id: Id0e7c12279b81ff32582e366ae5952f511ca0f98
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 529ebd3fb0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 0b26626159)
This commit is contained in:
Laszlo Agocs 2023-03-17 14:05:34 +01:00 committed by Qt Cherry-pick Bot
parent c201787599
commit 8be479b9d9
1 changed files with 11 additions and 0 deletions

View File

@ -258,6 +258,15 @@ void QSGRenderLoop::setInstance(QSGRenderLoop *instance)
void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window)
{
// Must always be called on the gui thread.
// Guard for recursion; relevant due to the MessageBox() on Windows.
static QSet<QQuickWindow *> recurseGuard;
if (recurseGuard.contains(window))
return;
recurseGuard.insert(window);
QString translatedMessage;
QString untranslatedMessage;
QQuickWindowPrivate::rhiCreationFailureMessage(QSGRhiSupport::instance()->rhiBackendName(),
@ -278,6 +287,8 @@ void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window)
#endif // Q_OS_WIN
if (!signalEmitted)
qFatal("%s", qPrintable(untranslatedMessage));
recurseGuard.remove(window);
}
#ifdef ENABLE_DEFAULT_BACKEND