OSDN Git Service

mark some environment queries as static and const
authorIvailo Monev <xakepa10@laimg.moc>
Mon, 30 Mar 2020 08:09:53 +0000 (08:09 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Mon, 30 Mar 2020 08:09:53 +0000 (08:09 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/global/qglobal.cpp
src/gui/graphicsview/qgraphicslayout_p.h
src/gui/kernel/qapplication.cpp
src/gui/kernel/qguiplatformplugin.cpp
src/gui/kernel/qlayout.cpp
src/gui/kernel/qwidget.cpp
src/gui/kernel/qwidget_x11.cpp
src/gui/painting/qbackingstore.cpp

index f24d51a..def9374 100644 (file)
@@ -1454,7 +1454,8 @@ void qt_message_output(QtMsgType msgType, const char *buf)
         fflush(stderr);
     }
 
-    if (msgType == QtFatalMsg || (msgType == QtWarningMsg && (!qgetenv("QT_FATAL_WARNINGS").isNull())))
+    static const bool fatalwarnings = qgetenv("QT_FATAL_WARNINGS").isNull();
+    if (msgType == QtFatalMsg || (msgType == QtWarningMsg && !fatalwarnings))
         abort(); // trap; generates core dump
 }
 
index 338be47..d3c49f4 100644 (file)
@@ -63,9 +63,7 @@ class QGraphicsWidget;
 #ifndef QT_NO_DEBUG
 inline bool qt_graphicsLayoutDebug()
 {
-    static int checked_env = -1;
-    if(checked_env == -1)
-        checked_env = !!qgetenv("QT_GRAPHICSLAYOUT_DEBUG").toInt();
+    static const int checked_env = !!qgetenv("QT_GRAPHICSLAYOUT_DEBUG").toInt();
     return checked_env;
 }
 #endif
index 6200ef7..3f24d78 100644 (file)
@@ -1046,7 +1046,7 @@ QStyle *QApplication::style()
         //
         QString style;
 #ifdef QT_BUILD_INTERNAL
-        QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
+        static const QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
 #endif
         if (!QApplicationPrivate::styleOverride.isEmpty()) {
             style = QApplicationPrivate::styleOverride;
index 991a68b..952c674 100644 (file)
@@ -57,7 +57,7 @@ QGuiPlatformPlugin *qt_guiPlatformPlugin()
     {
 #ifndef QT_NO_LIBRARY
 
-        QString key = QString::fromLocal8Bit(qgetenv("QT_PLATFORM_PLUGIN"));
+        static QString key = QString::fromLocal8Bit(qgetenv("QT_PLATFORM_PLUGIN"));
         if (key.isEmpty()) {
             key = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
         }
index 325741a..d445954 100644 (file)
@@ -812,10 +812,7 @@ bool QLayout::adoptLayout(QLayout *layout)
 #ifndef QT_NO_DEBUG
 static bool layoutDebug()
 {
-    static int checked_env = -1;
-    if(checked_env == -1)
-        checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt();
-
+    static const int checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt();
     return checked_env;
 }
 #endif
index 61e5850..95cbfd3 100644 (file)
@@ -1099,10 +1099,8 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
         }
     }
 
-    static int paintOnScreenEnv = -1;
-    if (paintOnScreenEnv == -1)
-        paintOnScreenEnv = qgetenv("QT_ONSCREEN_PAINT").toInt() > 0 ? 1 : 0;
-    if (paintOnScreenEnv == 1)
+    static const int paintOnScreenEnv = qgetenv("QT_ONSCREEN_PAINT").toInt();
+    if (paintOnScreenEnv)
         setAttribute(Qt::WA_PaintOnScreen);
 
     if (QApplication::testAttribute(Qt::AA_NativeWindows))
index 011dfc3..9321f25 100644 (file)
@@ -2531,7 +2531,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
             QApplication::sendEvent(q, &e);
         }
         if (isResize) {
-            static bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt();
+            static const bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt();
             // If we have a backing store with static contents, we have to disable the top-level
             // resize optimization in order to get invalidated regions for resized widgets.
             // The optimization discards all invalidateBuffer() calls since we're going to
index 490d455..de69766 100644 (file)
@@ -74,14 +74,14 @@ static inline void qt_flush(QWidget *widget, const QRegion &region, QWindowSurfa
     Q_ASSERT(tlw);
 
 #if !defined(QT_NO_DEBUG)
-    static int flushUpdate = qgetenv("QT_FLUSH_UPDATE").toInt();
+    static const int flushUpdate = qgetenv("QT_FLUSH_UPDATE").toInt();
     if (flushUpdate > 0)
         QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false);
 #endif
 
     //The performance hit by doing this should be negligible. However, be aware that
     //using this FPS when you have > 1 windowsurface can give you inaccurate FPS
-    static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
+    static const bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
     if (fpsDebug) {
         static QTime time = QTime::currentTime();
         static int frames = 0;
@@ -695,10 +695,7 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
     if (x->inTopLevelResize)
         return;
 
-    static int accelEnv = -1;
-    if (accelEnv == -1) {
-        accelEnv = qgetenv("QT_NO_FAST_MOVE").toInt() == 0;
-    }
+    static const int accelEnv = qgetenv("QT_NO_FAST_MOVE").toInt() == 0;
 
     QWidget *pw = q->parentWidget();
     QPoint toplevelOffset = pw->mapTo(tlw, QPoint());
@@ -777,10 +774,7 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy)
     if (!wbs)
         return;
 
-    static int accelEnv = -1;
-    if (accelEnv == -1) {
-        accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
-    }
+    static const int accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
 
     QRect scrollRect = rect & clipRect();
     bool overlapped = false;