From 836386b63244e2627948ea719bbbb57872cf794a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Fri, 10 Jan 2025 13:31:58 -0400 Subject: [PATCH] Re-enable ability to switch render modes under Qt 6 Fixes #880, where QSG_VISUALIZE modes were not working. Also fixed race condition crashes around use of OpenGL RHI and scene graph events. --- plugins/quickinspector/quickinspector.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/quickinspector/quickinspector.cpp b/plugins/quickinspector/quickinspector.cpp index f578f941c..39ead746d 100644 --- a/plugins/quickinspector/quickinspector.cpp +++ b/plugins/quickinspector/quickinspector.cpp @@ -301,25 +301,24 @@ void RenderModeRequest::apply() if (connection) disconnect(connection); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - // crashes in qrhigles2..bindShaderResources sometimes - return; -#endif - if (window && window->rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL) return; if (window) { - emit aboutToCleanSceneGraph(); const QByteArray mode = renderModeToString(RenderModeRequest::mode); QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(window); - QMetaObject::invokeMethod(window, "cleanupSceneGraph", Qt::DirectConnection); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - winPriv->visualizationMode = mode; + QObject::connect(window.get(), &QQuickWindow::beforeSynchronizing, this, [this, winPriv, mode]() { + emit aboutToCleanSceneGraph(); + QMetaObject::invokeMethod(window, "cleanupSceneGraph", Qt::DirectConnection); + winPriv->visualizationMode = mode; + emit sceneGraphCleanedUp(); }, static_cast(Qt::DirectConnection | Qt::SingleShotConnection)); #else + emit aboutToCleanSceneGraph(); + QMetaObject::invokeMethod(window, "cleanupSceneGraph", Qt::DirectConnection); winPriv->customRenderMode = mode; -#endif emit sceneGraphCleanedUp(); +#endif } QMetaObject::invokeMethod(this, "preFinished", Qt::QueuedConnection);