From 0aada37644762d4757f9f9b2a76e31389aa91b27 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 26 Aug 2019 13:31:58 +0200 Subject: Fix not printing logs with QSG_INFO when forcing rhi backend from C++ QQuickWindow::setScenegraphBackend() may be called before QQuickWindow gets a chance to create a render loop. If QSG_INFO (the env.var.) is used instead of the logging category (qt.scenegraph.general), some logs are not printed because the code that enables the logging category is not yet run. To prevent confusion, make sure the logging category gets enabled before the first potential qCDebug. In the worst case we check twice but that's fine. Change-Id: Ibfc0af05050adc9766c30a2d15c778b2a51823fe Reviewed-by: Andy Nichols --- src/quick/scenegraph/qsgrhisupport.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/quick/scenegraph/qsgrhisupport.cpp') diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 8bae24dc76..a92b6b0c84 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -109,6 +109,12 @@ void QSGRhiSupport::applySettings() { m_set = true; + // This is also done when creating the renderloop but we may be before that + // in case we get here due to a setScenegraphBackend() -> configure() early + // on in main(). Avoid losing info logs since troubleshooting gets + // confusing otherwise. + QSGRhiSupport::checkEnvQSgInfo(); + if (m_requested.valid) { // explicit rhi backend request from C++ (e.g. via QQuickWindow) m_enableRhi = m_requested.rhi; @@ -203,6 +209,13 @@ QSGRhiSupport *QSGRhiSupport::staticInst() return &inst; } +void QSGRhiSupport::checkEnvQSgInfo() +{ + // For compatibility with 5.3 and earlier's QSG_INFO environment variables + if (qEnvironmentVariableIsSet("QSG_INFO")) + const_cast(QSG_LOG_INFO()).setEnabled(QtDebugMsg, true); +} + void QSGRhiSupport::configure(QSGRendererInterface::GraphicsApi api) { Q_ASSERT(QSGRendererInterface::isApiRhiBased(api)); -- cgit v1.2.3