diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-08-26 13:31:58 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-08-29 11:01:50 +0200 |
commit | 0aada37644762d4757f9f9b2a76e31389aa91b27 (patch) | |
tree | 8790a4448598d874ac4384afffa2497c01ae704d | |
parent | cda5721e0efbce4b35ba1692c70f8e90b0fd6726 (diff) |
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 <andy.nichols@qt.io>
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 4 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport.cpp | 13 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport_p.h | 2 |
3 files changed, 16 insertions, 3 deletions
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 58dfd97e03..08d1c726ab 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -214,9 +214,7 @@ QSGRenderLoop *QSGRenderLoop::instance() { if (!s_instance) { - // For compatibility with 5.3 and earlier's QSG_INFO environment variables - if (qEnvironmentVariableIsSet("QSG_INFO")) - const_cast<QLoggingCategory &>(QSG_LOG_INFO()).setEnabled(QtDebugMsg, true); + QSGRhiSupport::checkEnvQSgInfo(); s_instance = QSGContext::createWindowManager(); #ifdef ENABLE_DEFAULT_BACKEND 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<QLoggingCategory &>(QSG_LOG_INFO()).setEnabled(QtDebugMsg, true); +} + void QSGRhiSupport::configure(QSGRendererInterface::GraphicsApi api) { Q_ASSERT(QSGRendererInterface::isApiRhiBased(api)); diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h index 0e1881aa00..f2d5837bba 100644 --- a/src/quick/scenegraph/qsgrhisupport_p.h +++ b/src/quick/scenegraph/qsgrhisupport_p.h @@ -126,6 +126,8 @@ public: QImage grabAndBlockInCurrentFrame(QRhi *rhi, QRhiSwapChain *swapchain); + static void checkEnvQSgInfo(); + private: QSGRhiSupport(); void applySettings(); |