From 10e3ce9e169d9c38c9cfd15a8729fa091694bf60 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 7 Sep 2014 21:44:19 +0200 Subject: [PATCH] QWidget: simplify reading of an env-var in create() Instead of initializing paintOnScreenEnv to -1 (thus forcing the variable into the data segment), and then overwriting the -1 with a read from the env-var, dynamically initialize the variable from the env-var directly, thus allowing the variable back into the bss segment (which doesn't occupy storage in the executable). There may have been a reason to do it this way when the old code could fail due to the memory allocation involved, but now with qEnvironmentVariableIntValue(), that is no longer a reason. Change-Id: I6547a81f69b0b57dc49bb4dd3ba1865ce8ac5b86 Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidget.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c6fcb98f52..190fd3a134 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1283,10 +1283,8 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) } - static int paintOnScreenEnv = -1; - if (paintOnScreenEnv == -1) - paintOnScreenEnv = qEnvironmentVariableIntValue("QT_ONSCREEN_PAINT") > 0 ? 1 : 0; - if (paintOnScreenEnv == 1) + static const bool paintOnScreenEnv = qEnvironmentVariableIntValue("QT_ONSCREEN_PAINT") > 0; + if (paintOnScreenEnv) setAttribute(Qt::WA_PaintOnScreen); if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows))