Skip to content

Commit

Permalink
Re-enable ability to switch render modes under Qt 6
Browse files Browse the repository at this point in the history
Fixes #880, where QSG_VISUALIZE modes were not working.

Also fixed race condition crashes around use of OpenGL RHI and
scene graph events.
  • Loading branch information
Javier O. Cordero Pérez authored and Cuperino committed Jan 11, 2025
1 parent 753d7af commit 9ced559
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions plugins/quickinspector/quickinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::ConnectionType>(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);
Expand Down

0 comments on commit 9ced559

Please sign in to comment.