From 4d10e55d4d666f5557a51d43a1bd4b1f172829ac Mon Sep 17 00:00:00 2001
From: Alexander Volkov <a.volkov@rusbitech.ru>
Date: Fri, 5 Feb 2016 14:56:06 +0300
Subject: [PATCH] Fix detection of the proxy base style when QT_STYLE_OVERRIDE
 is set

QProxyStyle checks QApplicationPrivate::styleOverride but ignores
QT_STYLE_OVERRIDE when it is trying to detect the name of the base
style.
Set styleOverride from QT_STYLE_OVERRIDE to make it work. Thus there
is no need to check QT_STYLE_OVERRIDE from multiple places.

Change-Id: I2a64b5ff5443701f800ef5d2a9cb425068f909f1
Task-number: QTBUG-52596
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
---
 src/widgets/kernel/qapplication.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index b34380dbc3f..a459a57482c 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -464,6 +464,9 @@ QDesktopWidget *qt_desktopWidget = 0;                // root window widgets
 */
 void QApplicationPrivate::process_cmdline()
 {
+    if (styleOverride.isEmpty() && qEnvironmentVariableIsSet("QT_STYLE_OVERRIDE"))
+        styleOverride = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
+
     if (!styleOverride.isEmpty()) {
         if (app_style) {
             delete app_style;
@@ -1120,11 +1123,8 @@ QStyle *QApplication::style()
         // Compile-time search for default style
         //
         QString style;
-        QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
         if (!QApplicationPrivate::styleOverride.isEmpty()) {
             style = QApplicationPrivate::styleOverride;
-        } else if (!envStyle.isEmpty()) {
-            style = envStyle;
         } else {
             style = QApplicationPrivate::desktopStyleKey();
         }
-- 
GitLab