Use qEnvironmentVariableIntValue() instead of qgetenv().toInt()

The docs tell us that it's faster.

Pick-to: 6.2
Change-Id: Ib828ed9a10bbb617670a61e7525cbbe25704815d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
Shawn Rutledge 2021-08-13 16:00:13 +02:00
parent e02964f01a
commit ca89437d00
4 changed files with 5 additions and 5 deletions

View File

@ -59,13 +59,13 @@
app.setOrganizationDomain("qt-project.org");\
app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\
QQuickView view;\
if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
if (qEnvironmentVariableIntValue("QT_QUICK_CORE_PROFILE")) {\
QSurfaceFormat f = view.format();\
f.setProfile(QSurfaceFormat::CoreProfile);\
f.setVersion(4, 4);\
view.setFormat(f);\
}\
if (qgetenv("QT_QUICK_MULTISAMPLE").toInt()) {\
if (qEnvironmentVariableIntValue("QT_QUICK_MULTISAMPLE")) {\
QSurfaceFormat f = view.format();\
f.setSamples(4);\
view.setFormat(f);\

View File

@ -55,7 +55,7 @@ int qt_sg_envInt(const char *name, int defaultValue)
if (Q_LIKELY(!qEnvironmentVariableIsSet(name)))
return defaultValue;
bool ok = false;
int value = qgetenv(name).toInt(&ok);
int value = qEnvironmentVariableIntValue(name, &ok);
return ok ? value : defaultValue;
}

View File

@ -79,7 +79,7 @@ void tst_Snippets::initTestCase()
QDir screenshotsDir(QDir::current().filePath("screenshots"));
takeScreenshots = qgetenv("SCREENSHOTS").toInt();
takeScreenshots = qEnvironmentVariableIntValue("SCREENSHOTS");
if (takeScreenshots)
QVERIFY(screenshotsDir.exists() || QDir::current().mkpath("screenshots"));

View File

@ -42,7 +42,7 @@
using namespace QQuickVisualTestUtil;
static int qt_verbose = qgetenv("VERBOSE").toInt() != 0;
static int qt_verbose = qEnvironmentVariableIntValue("VERBOSE") != 0;
Q_GLOBAL_STATIC(QObjectList, qt_qobjects)