Skip to content

Commit 9ced559

Browse files
Javier O. Cordero PérezCuperino
authored andcommitted
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.
1 parent 753d7af commit 9ced559

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

plugins/quickinspector/quickinspector.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,25 +301,24 @@ void RenderModeRequest::apply()
301301
if (connection)
302302
disconnect(connection);
303303

304-
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
305-
// crashes in qrhigles2..bindShaderResources sometimes
306-
return;
307-
#endif
308-
309304
if (window && window->rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL)
310305
return;
311306

312307
if (window) {
313-
emit aboutToCleanSceneGraph();
314308
const QByteArray mode = renderModeToString(RenderModeRequest::mode);
315309
QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(window);
316-
QMetaObject::invokeMethod(window, "cleanupSceneGraph", Qt::DirectConnection);
317310
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
318-
winPriv->visualizationMode = mode;
311+
QObject::connect(window.get(), &QQuickWindow::beforeSynchronizing, this, [this, winPriv, mode]() {
312+
emit aboutToCleanSceneGraph();
313+
QMetaObject::invokeMethod(window, "cleanupSceneGraph", Qt::DirectConnection);
314+
winPriv->visualizationMode = mode;
315+
emit sceneGraphCleanedUp(); }, static_cast<Qt::ConnectionType>(Qt::DirectConnection | Qt::SingleShotConnection));
319316
#else
317+
emit aboutToCleanSceneGraph();
318+
QMetaObject::invokeMethod(window, "cleanupSceneGraph", Qt::DirectConnection);
320319
winPriv->customRenderMode = mode;
321-
#endif
322320
emit sceneGraphCleanedUp();
321+
#endif
323322
}
324323

325324
QMetaObject::invokeMethod(this, "preFinished", Qt::QueuedConnection);

0 commit comments

Comments
 (0)