diff --git a/src/libs/utils/benchmarker.cpp b/src/libs/utils/benchmarker.cpp index 06a8132fb09..dfbdf1242e8 100644 --- a/src/libs/utils/benchmarker.cpp +++ b/src/libs/utils/benchmarker.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "benchmarker.h" +#include "environment.h" #include #include @@ -48,7 +49,7 @@ void Benchmarker::report(const QString &testsuite, void Benchmarker::report(const QLoggingCategory &cat, const QString &testsuite, const QString &testcase, qint64 ms, const QString &tags) { - static const QByteArray quitAfter = qgetenv("QTC_QUIT_AFTER_BENCHMARK"); + static const QByteArray quitAfter = qtcEnvironmentVariable("QTC_QUIT_AFTER_BENCHMARK").toLatin1(); QString t = "unit=ms"; if (!tags.isEmpty()) t += "," + tags; diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index d82448d0e4c..725fbeea24b 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -644,13 +644,13 @@ bool ProcessArgs::prepareCommand(const CommandLine &cmdLine, QString *outCmd, Pr *outCmd = executable.toString(); } else { if (executable.osType() == OsTypeWindows) { - *outCmd = QString::fromLatin1(qgetenv("COMSPEC")); + *outCmd = qtcEnvironmentVariable("COMSPEC"); *outArgs = ProcessArgs::createWindowsArgs(QLatin1String("/v:off /s /c \"") + quoteArg(executable.toUserOutput()) + ' ' + arguments + '"'); } else { if (err != ProcessArgs::FoundMeta) return false; - *outCmd = qEnvironmentVariable("SHELL", "/bin/sh"); + *outCmd = qtcEnvironmentVariable("SHELL", "/bin/sh"); *outArgs = ProcessArgs::createUnixArgs({"-c", quoteArg(executable.toString()) + ' ' + arguments}); } } diff --git a/src/libs/utils/filesystemmodel.cpp b/src/libs/utils/filesystemmodel.cpp index 2765d2bfbac..645d979fc9c 100644 --- a/src/libs/utils/filesystemmodel.cpp +++ b/src/libs/utils/filesystemmodel.cpp @@ -3,6 +3,7 @@ #include "filesystemmodel.h" +#include "environment.h" #include "hostosinfo.h" #include "qtcassert.h" @@ -432,7 +433,8 @@ ExtendedInformation FileInfoGatherer::getInfo(const QFileInfo &fileInfo) const info.displayType = m_iconProvider->type(fileInfo); if (useFileSystemWatcher()) { // ### Not ready to listen all modifications by default - static const bool watchFiles = qEnvironmentVariableIsSet("QT_FILESYSTEMMODEL_WATCH_FILES"); + static const bool watchFiles = qtcEnvironmentVariableIsSet( + "QT_FILESYSTEMMODEL_WATCH_FILES"); if (watchFiles) { if (!fileInfo.exists() && !fileInfo.isSymLink()) { const_cast(this)-> diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index bda2cf195ce..d2fc6c3b327 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -4,6 +4,7 @@ #include "qtcprocess.h" #include "algorithm.h" +#include "environment.h" #include "guard.h" #include "hostosinfo.h" #include "launcherinterface.h" @@ -50,7 +51,7 @@ class MeasureAndRun public: MeasureAndRun(const char *functionName) : m_functionName(functionName) - , m_measureProcess(qEnvironmentVariableIsSet("QTC_MEASURE_PROCESS")) + , m_measureProcess(qtcEnvironmentVariableIsSet("QTC_MEASURE_PROCESS")) {} template std::invoke_result_t measureAndRun(Function &&function, Args&&... args) @@ -507,7 +508,7 @@ private: static ProcessImpl defaultProcessImpl() { - if (qEnvironmentVariableIsSet("QTC_USE_QPROCESS")) + if (qtcEnvironmentVariableIsSet("QTC_USE_QPROCESS")) return ProcessImpl::QProcess; return ProcessImpl::ProcessLauncher; } diff --git a/src/libs/utils/terminalprocess.cpp b/src/libs/utils/terminalprocess.cpp index e5b1cdcaac7..c140a1e6e63 100644 --- a/src/libs/utils/terminalprocess.cpp +++ b/src/libs/utils/terminalprocess.cpp @@ -182,15 +182,15 @@ void TerminalImpl::start() QStringList envStrings = env; // add PATH if necessary (for DLL loading) if (envStrings.filter(QRegularExpression("^PATH=.*", QRegularExpression::CaseInsensitiveOption)).isEmpty()) { - QByteArray path = qgetenv("PATH"); + const QString path = qtcEnvironmentVariable("PATH"); if (!path.isEmpty()) - envStrings.prepend(QString::fromLatin1("PATH=%1").arg(QString::fromLocal8Bit(path))); + envStrings.prepend(QString::fromLatin1("PATH=%1").arg(path)); } // add systemroot if needed if (envStrings.filter(QRegularExpression("^SystemRoot=.*", QRegularExpression::CaseInsensitiveOption)).isEmpty()) { - QByteArray systemRoot = qgetenv("SystemRoot"); + const QString systemRoot = qtcEnvironmentVariable("SystemRoot"); if (!systemRoot.isEmpty()) - envStrings.prepend(QString::fromLatin1("SystemRoot=%1").arg(QString::fromLocal8Bit(systemRoot))); + envStrings.prepend(QString::fromLatin1("SystemRoot=%1").arg(systemRoot)); } return envStrings; }(); @@ -324,7 +324,7 @@ void TerminalImpl::start() " is currently not supported.")); return; } - pcmd = qEnvironmentVariable("SHELL", "/bin/sh"); + pcmd = qtcEnvironmentVariable("SHELL", "/bin/sh"); pargs = ProcessArgs::createUnixArgs( {"-c", (ProcessArgs::quoteArg(m_setup.m_commandLine.executable().toString()) + ' ' + m_setup.m_commandLine.arguments())});