aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgrhisupport.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-08-26 13:31:58 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-08-29 11:01:50 +0200
commit0aada37644762d4757f9f9b2a76e31389aa91b27 (patch)
tree8790a4448598d874ac4384afffa2497c01ae704d /src/quick/scenegraph/qsgrhisupport.cpp
parentcda5721e0efbce4b35ba1692c70f8e90b0fd6726 (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>
Diffstat (limited to 'src/quick/scenegraph/qsgrhisupport.cpp')
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp13
1 files changed, 13 insertions, 0 deletions
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));