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 overdraw, and other modes, were
not working.

Also fixes race condition crashes around use of  OpenGL RHI and
scene graph events.
  • Loading branch information
Javier O. Cordero Pérez committed Jan 9, 2025
1 parent e79cd08 commit 8b06a07
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions plugins/quickinspector/quickinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,25 +301,30 @@ 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();
switch (window->rendererInterface()->graphicsApi()) {
// Compatible render interfaces
case QSGRendererInterface::OpenGL:
break;
default:
return;
}

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 8b06a07

Please sign in to comment.