mark some environment queries as static and const

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-03-30 08:09:53 +00:00
parent 85077cc320
commit 34ef1069b0
8 changed files with 13 additions and 25 deletions

View 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
}

View 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

View 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;

View 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"));
}

View 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

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

View 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

View 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;