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 <Friedemann.Kleint@digia.com>
bb10
Marc Mutz 2014-09-07 21:44:19 +02:00
parent d8838ee126
commit 10e3ce9e16
1 changed files with 2 additions and 4 deletions

View File

@ -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))