diff --git a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp index 8cfaa918530..1731d3bcb3c 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp @@ -53,9 +53,9 @@ static std::vector> autoDetectCMakeTools() path = Utils::filteredUnique(path); if (HostOsInfo::isWindowsHost()) { - for (auto envVar : {"ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"}) { - if (qEnvironmentVariableIsSet(envVar)) { - const QString progFiles = qEnvironmentVariable(envVar); + for (const auto &envVar : QStringList{"ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"}) { + if (qtcEnvironmentVariableIsSet(envVar)) { + const QString progFiles = qtcEnvironmentVariable(envVar); path.append(FilePath::fromUserInput(progFiles + "/CMake")); path.append(FilePath::fromUserInput(progFiles + "/CMake/bin")); } diff --git a/src/plugins/projectexplorer/abi.cpp b/src/plugins/projectexplorer/abi.cpp index 6ca18d88afb..ab01d33563d 100644 --- a/src/plugins/projectexplorer/abi.cpp +++ b/src/plugins/projectexplorer/abi.cpp @@ -4,6 +4,7 @@ #include "abi.h" #include +#include #include #include @@ -1273,7 +1274,7 @@ void ProjectExplorer::ProjectExplorerPlugin::testAbiOfBinary_data() // Clone test data from: https://git.qt.io/chstenge/creator-test-data // Set up prefix for test data now that we can be sure to have some tests to run: - QString prefix = QString::fromLocal8Bit(qgetenv("QTC_TEST_EXTRADATALOCATION")); + QString prefix = Utils::qtcEnvironmentVariable("QTC_TEST_EXTRADATALOCATION"); if (prefix.isEmpty()) return; prefix += "/projectexplorer/abi"; diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index 14a96c96f7c..bae444550a7 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -37,7 +38,7 @@ const char configFileC[] = "wizard.xml"; static bool enableLoadTemplateFiles() { #ifdef WITH_TESTS - static bool value = qEnvironmentVariableIsEmpty("QTC_DISABLE_LOAD_TEMPLATES_FOR_TEST"); + static bool value = qtcEnvironmentVariableIsEmpty("QTC_DISABLE_LOAD_TEMPLATES_FOR_TEST"); #else static bool value = true; #endif diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp index 20a3ca98bde..3d2a3736a55 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp @@ -5,6 +5,7 @@ #include "customwizard.h" #include "customwizardparameters.h" +#include #include #include #include @@ -46,7 +47,7 @@ QStringList fixGeneratorScript(const QString &configFile, QString binary) if (!extension.isEmpty() && extension.compare(QLatin1String("exe"), Qt::CaseInsensitive) != 0) { rc.push_front(QLatin1String("/C")); - rc.push_front(QString::fromLocal8Bit(qgetenv("COMSPEC"))); + rc.push_front(qtcEnvironmentVariable("COMSPEC")); if (rc.front().isEmpty()) rc.front() = QLatin1String("cmd.exe"); } diff --git a/src/plugins/projectexplorer/devicesupport/sshparameters.cpp b/src/plugins/projectexplorer/devicesupport/sshparameters.cpp index a1a12218ffb..26cc997afaa 100644 --- a/src/plugins/projectexplorer/devicesupport/sshparameters.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshparameters.cpp @@ -106,29 +106,29 @@ bool operator!=(const SshParameters &p1, const SshParameters &p2) namespace SshTest { const QString getHostFromEnvironment() { - const QString host = QString::fromLocal8Bit(qgetenv("QTC_SSH_TEST_HOST")); - if (host.isEmpty() && qEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) + const QString host = qtcEnvironmentVariable("QTC_SSH_TEST_HOST"); + if (host.isEmpty() && qtcEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) return QString("127.0.0.1"); return host; } quint16 getPortFromEnvironment() { - const int port = qEnvironmentVariableIntValue("QTC_SSH_TEST_PORT"); + const int port = qtcEnvironmentVariableIntValue("QTC_SSH_TEST_PORT"); return port != 0 ? quint16(port) : 22; } const QString getUserFromEnvironment() { - return QString::fromLocal8Bit(qgetenv("QTC_SSH_TEST_USER")); + return qtcEnvironmentVariable("QTC_SSH_TEST_USER"); } const QString getKeyFileFromEnvironment() { const FilePath defaultKeyFile = FileUtils::homePath() / ".ssh/id_rsa"; - const QString keyFile = QString::fromLocal8Bit(qgetenv("QTC_SSH_TEST_KEYFILE")); + const QString keyFile = qtcEnvironmentVariable("QTC_SSH_TEST_KEYFILE"); if (keyFile.isEmpty()) { - if (qEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) + if (qtcEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) return defaultKeyFile.toString(); } return keyFile; @@ -145,7 +145,7 @@ const QString userAtHost() SshParameters getParameters() { SshParameters params; - if (!qEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) { + if (!qtcEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) { params.setUserName(getUserFromEnvironment()); params.privateKeyFile = FilePath::fromUserInput(getKeyFileFromEnvironment()); } @@ -160,7 +160,7 @@ SshParameters getParameters() bool checkParameters(const SshParameters ¶ms) { - if (qEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) + if (qtcEnvironmentVariableIsSet("QTC_SSH_TEST_DEFAULTS")) return true; if (params.host().isEmpty()) { qWarning("No hostname provided. Set QTC_SSH_TEST_HOST."); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 85ef4726b32..950adf6ce49 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -492,7 +493,7 @@ static QStringList environmentTemplatesPaths() { QStringList paths; - QString envTempPath = QString::fromLocal8Bit(qgetenv("QTCREATOR_TEMPLATES_PATH")); + QString envTempPath = qtcEnvironmentVariable("QTCREATOR_TEMPLATES_PATH"); if (!envTempPath.isEmpty()) { for (const QString &path : envTempPath diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 35e7404ff15..cbf45965994 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -13,13 +13,14 @@ #include #include +#include #include #include +#include #include #include #include #include -#include #include #include @@ -196,7 +197,7 @@ static QString windowsProgramFilesDir() #else const char programFilesC[] = "ProgramFiles"; #endif - return QDir::fromNativeSeparators(QFile::decodeName(qgetenv(programFilesC))); + return QDir::fromNativeSeparators(qtcEnvironmentVariable(programFilesC)); } static Utils::optional installationFromPathAndVersion( @@ -2110,8 +2111,7 @@ Utils::optional MsvcToolChain::generateEnvironmentSettings(const Utils: runEnv.unset(QLatin1String("ORIGINALPATH")); run.setEnvironment(runEnv); run.setTimeoutS(60); - Utils::FilePath cmdPath = Utils::FilePath::fromUserInput( - QString::fromLocal8Bit(qgetenv("COMSPEC"))); + Utils::FilePath cmdPath = Utils::FilePath::fromUserInput(qtcEnvironmentVariable("COMSPEC")); if (cmdPath.isEmpty()) cmdPath = env.searchInPath(QLatin1String("cmd.exe")); // Windows SDK setup scripts require command line switches for environment expansion. diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp index 39ba3c98ba1..f6d91b935bf 100644 --- a/src/plugins/projectexplorer/userfileaccessor.cpp +++ b/src/plugins/projectexplorer/userfileaccessor.cpp @@ -15,8 +15,9 @@ #include #include -#include +#include #include +#include #include #include @@ -184,10 +185,10 @@ static QString generateSuffix(const QString &suffix) // Return path to shared directory for .user files, create if necessary. static inline Utils::optional defineExternalUserFileDir() { - static const char userFilePathVariable[] = "QTC_USER_FILE_PATH"; - if (Q_LIKELY(!qEnvironmentVariableIsSet(userFilePathVariable))) + const char userFilePathVariable[] = "QTC_USER_FILE_PATH"; + if (Q_LIKELY(!qtcEnvironmentVariableIsSet(userFilePathVariable))) return nullopt; - const QFileInfo fi(QFile::decodeName(qgetenv(userFilePathVariable))); + const QFileInfo fi(qtcEnvironmentVariable(userFilePathVariable)); const QString path = fi.absoluteFilePath(); if (fi.isDir() || fi.isSymLink()) return path; @@ -379,21 +380,21 @@ QVariant UserFileAccessor::retrieveSharedSettings() const FilePath UserFileAccessor::projectUserFile() const { - static const QString qtcExt = QLatin1String(qgetenv("QTC_EXTENSION")); + static const QString qtcExt = qtcEnvironmentVariable("QTC_EXTENSION"); return m_project->projectFilePath() .stringAppended(generateSuffix(qtcExt.isEmpty() ? FILE_EXTENSION_STR : qtcExt)); } FilePath UserFileAccessor::externalUserFile() const { - static const QString qtcExt = QFile::decodeName(qgetenv("QTC_EXTENSION")); + static const QString qtcExt = qtcEnvironmentVariable("QTC_EXTENSION"); return externalUserFilePath(m_project->projectFilePath(), generateSuffix(qtcExt.isEmpty() ? FILE_EXTENSION_STR : qtcExt)); } FilePath UserFileAccessor::sharedFile() const { - static const QString qtcExt = QLatin1String(qgetenv("QTC_SHARED_EXTENSION")); + static const QString qtcExt = qtcEnvironmentVariable("QTC_SHARED_EXTENSION"); return m_project->projectFilePath() .stringAppended(generateSuffix(qtcExt.isEmpty() ? ".shared" : qtcExt)); } diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index 057e0f4fe25..a3657f150e7 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,7 @@ public: } ~OpTimer() { - if (qEnvironmentVariableIsSet(Constants::QBS_PROFILING_ENV)) { + if (qtcEnvironmentVariableIsSet(Constants::QBS_PROFILING_ENV)) { MessageManager::writeSilently( QString("operation %1 took %2ms").arg(QLatin1String(m_name)).arg(m_timer.elapsed())); } diff --git a/src/plugins/qbsprojectmanager/qbssession.cpp b/src/plugins/qbsprojectmanager/qbssession.cpp index 6787d48850b..050a5cf1beb 100644 --- a/src/plugins/qbsprojectmanager/qbssession.cpp +++ b/src/plugins/qbsprojectmanager/qbssession.cpp @@ -247,10 +247,10 @@ void QbsSession::sendRequest(const QJsonObject &request) qDebug() << request.value("type").toString() << d->currentRequest.value("type").toString(); return); d->currentRequest = request; - const QString logLevelFromEnv = qEnvironmentVariable("QBS_LOG_LEVEL"); + const QString logLevelFromEnv = qtcEnvironmentVariable("QBS_LOG_LEVEL"); if (!logLevelFromEnv.isEmpty()) d->currentRequest.insert("log-level", logLevelFromEnv); - if (!qEnvironmentVariableIsEmpty(Constants::QBS_PROFILING_ENV)) + if (!qtcEnvironmentVariableIsEmpty(Constants::QBS_PROFILING_ENV)) d->currentRequest.insert("log-time", true); if (d->state == State::Active) sendQueuedRequest(); diff --git a/src/plugins/qmakeprojectmanager/externaleditors.cpp b/src/plugins/qmakeprojectmanager/externaleditors.cpp index 0590b4f1d0a..6c178589de3 100644 --- a/src/plugins/qmakeprojectmanager/externaleditors.cpp +++ b/src/plugins/qmakeprojectmanager/externaleditors.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -153,7 +154,7 @@ bool ExternalQtEditor::getEditorLaunchData(const Utils::FilePath &filePath, data->binary = findFirstCommand(qtVersionsToCheck, m_commandForQtVersion); // fallback if (data->binary.isEmpty()) { - const QString path = qEnvironmentVariable("PATH"); + const QString path = qtcEnvironmentVariable("PATH"); data->binary = Utils::QtcProcess::locateBinary(path, m_commandForQtVersion(nullptr)); } diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 444062268eb..a0416e17ceb 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -35,8 +36,7 @@ namespace Internal { static bool debugExamples() { - static bool isDebugging = qEnvironmentVariableIsSet("QTC_DEBUG_EXAMPLESMODEL"); - return isDebugging; + return qtcEnvironmentVariableIsSet("QTC_DEBUG_EXAMPLESMODEL"); } static const char kSelectedExampleSetKey[] = "WelcomePage/SelectedExampleSet"; diff --git a/src/plugins/remotelinux/x11forwardingaspect.cpp b/src/plugins/remotelinux/x11forwardingaspect.cpp index fd36314f5fb..a470bdb5313 100644 --- a/src/plugins/remotelinux/x11forwardingaspect.cpp +++ b/src/plugins/remotelinux/x11forwardingaspect.cpp @@ -5,6 +5,7 @@ #include "remotelinuxtr.h" +#include #include #include @@ -12,7 +13,10 @@ using namespace Utils; namespace RemoteLinux { -static QString defaultDisplay() { return qEnvironmentVariable("DISPLAY"); } +static QString defaultDisplay() +{ + return qtcEnvironmentVariable("DISPLAY"); +} X11ForwardingAspect::X11ForwardingAspect(const MacroExpander *expander) : m_macroExpander(expander)