From e1b6054ff849d4376b98dc59ceaa838e3b33b056 Mon Sep 17 00:00:00 2001 From: AMZN-Phil Date: Fri, 19 Nov 2021 19:13:19 -0800 Subject: [PATCH 1/5] Fix Project Manager not finding CMake on Windows Signed-off-by: AMZN-Phil --- .../Platform/Windows/ProjectUtils_windows.cpp | 30 ++++++++++--------- .../Source/ProjectBuilderWorker.cpp | 5 +--- .../ProjectManager/Source/ProjectUtils.cpp | 4 --- .../ProjectManager/Source/ProjectUtils.h | 4 +-- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp b/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp index d08da1d5e1..365aac7069 100644 --- a/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp +++ b/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp @@ -21,7 +21,7 @@ namespace O3DE::ProjectManager { namespace ProjectUtils { - AZ::Outcome GetCommandLineProcessEnvironment() + AZ::Outcome SetupCommandLineProcessEnvironment() { // Use the engine path to insert a path for cmake auto engineInfoResult = PythonBindingsInterface::Get()->GetEngineInfo(); @@ -31,26 +31,30 @@ namespace O3DE::ProjectManager } auto engineInfo = engineInfoResult.GetValue(); - QProcessEnvironment currentEnvironment(QProcessEnvironment::systemEnvironment()); - - // Append cmake path to PATH incase it is missing + // Append cmake path to the current environment PATH incase it is missing, since if + // we are starting CMake itself the current application needs to find it using Path + // This also takes affect for all child processes. QDir cmakePath(engineInfo.m_path); cmakePath.cd("cmake/runtime/bin"); - QString pathValue = currentEnvironment.value("PATH"); - pathValue += ";" + cmakePath.path(); - currentEnvironment.insert("PATH", pathValue); - return AZ::Success(currentEnvironment); + QString pathEnv = qEnvironmentVariable("Path"); + if (!pathEnv.contains(cmakePath.path())) + { + pathEnv += ";" + cmakePath.path(); + qputenv("Path", pathEnv.toStdString().c_str()); + } + + return AZ::Success(); } AZ::Outcome FindSupportedCompilerForPlatform() { // Validate that cmake is installed - auto cmakeProcessEnvResult = GetCommandLineProcessEnvironment(); + auto cmakeProcessEnvResult = SetupCommandLineProcessEnvironment(); if (!cmakeProcessEnvResult.IsSuccess()) { return AZ::Failure(cmakeProcessEnvResult.GetError()); } - auto cmakeVersionQueryResult = ExecuteCommandResult("cmake", QStringList{"--version"}, cmakeProcessEnvResult.GetValue()); + auto cmakeVersionQueryResult = ExecuteCommandResult("cmake", QStringList{"--version"}); if (!cmakeVersionQueryResult.IsSuccess()) { return AZ::Failure(QObject::tr("CMake not found. \n\n" @@ -104,7 +108,7 @@ namespace O3DE::ProjectManager AZ::Outcome OpenCMakeGUI(const QString& projectPath) { - AZ::Outcome processEnvResult = GetCommandLineProcessEnvironment(); + AZ::Outcome processEnvResult = SetupCommandLineProcessEnvironment(); if (!processEnvResult.IsSuccess()) { return AZ::Failure(processEnvResult.GetError()); @@ -118,7 +122,6 @@ namespace O3DE::ProjectManager } QProcess process; - process.setProcessEnvironment(processEnvResult.GetValue()); // if the project build path is relative, it should be relative to the project path process.setWorkingDirectory(projectPath); @@ -139,7 +142,6 @@ namespace O3DE::ProjectManager return ExecuteCommandResultModalDialog( "cmd.exe", QStringList{"/c", batPath}, - QProcessEnvironment::systemEnvironment(), QObject::tr("Running get_python script...")); } @@ -157,7 +159,7 @@ namespace O3DE::ProjectManager .arg(shortcutPath) .arg(targetPath) .arg(arguments.join(' ')); - auto createShortcutResult = ExecuteCommandResult(cmd, QStringList{"-Command", arg}, QProcessEnvironment::systemEnvironment()); + auto createShortcutResult = ExecuteCommandResult(cmd, QStringList{"-Command", arg}); if (!createShortcutResult.IsSuccess()) { return AZ::Failure(QObject::tr("Failed to create desktop shortcut %1

" diff --git a/Code/Tools/ProjectManager/Source/ProjectBuilderWorker.cpp b/Code/Tools/ProjectManager/Source/ProjectBuilderWorker.cpp index c6a6b20a1d..7ec691fd81 100644 --- a/Code/Tools/ProjectManager/Source/ProjectBuilderWorker.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectBuilderWorker.cpp @@ -117,18 +117,16 @@ namespace O3DE::ProjectManager // Show some kind of progress with very approximate estimates UpdateProgress(++m_progressEstimate); - auto currentEnvironmentRequest = ProjectUtils::GetCommandLineProcessEnvironment(); + auto currentEnvironmentRequest = ProjectUtils::SetupCommandLineProcessEnvironment(); if (!currentEnvironmentRequest.IsSuccess()) { QStringToAZTracePrint(currentEnvironmentRequest.GetError()); return AZ::Failure(currentEnvironmentRequest.GetError()); } - QProcessEnvironment currentEnvironment = currentEnvironmentRequest.GetValue(); m_configProjectProcess = new QProcess(this); m_configProjectProcess->setProcessChannelMode(QProcess::MergedChannels); m_configProjectProcess->setWorkingDirectory(m_projectInfo.m_path); - m_configProjectProcess->setProcessEnvironment(currentEnvironment); auto cmakeGenerateArgumentsResult = ConstructCmakeGenerateProjectArguments(engineInfo.m_thirdPartyPath); if (!cmakeGenerateArgumentsResult.IsSuccess()) @@ -181,7 +179,6 @@ namespace O3DE::ProjectManager m_buildProjectProcess = new QProcess(this); m_buildProjectProcess->setProcessChannelMode(QProcess::MergedChannels); m_buildProjectProcess->setWorkingDirectory(m_projectInfo.m_path); - m_buildProjectProcess->setProcessEnvironment(currentEnvironment); auto cmakeBuildArgumentsResult = ConstructCmakeBuildCommandArguments(); if (!cmakeBuildArgumentsResult.IsSuccess()) diff --git a/Code/Tools/ProjectManager/Source/ProjectUtils.cpp b/Code/Tools/ProjectManager/Source/ProjectUtils.cpp index 4a0e1c153c..b7748d8aa2 100644 --- a/Code/Tools/ProjectManager/Source/ProjectUtils.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectUtils.cpp @@ -520,12 +520,10 @@ namespace O3DE::ProjectManager AZ::Outcome ExecuteCommandResultModalDialog( const QString& cmd, const QStringList& arguments, - const QProcessEnvironment& processEnv, const QString& title) { QString resultOutput; QProcess execProcess; - execProcess.setProcessEnvironment(processEnv); execProcess.setProcessChannelMode(QProcess::MergedChannels); QProgressDialog dialog(title, QObject::tr("Cancel"), /*minimum=*/0, /*maximum=*/0); @@ -611,11 +609,9 @@ namespace O3DE::ProjectManager AZ::Outcome ExecuteCommandResult( const QString& cmd, const QStringList& arguments, - const QProcessEnvironment& processEnv, int commandTimeoutSeconds /*= ProjectCommandLineTimeoutSeconds*/) { QProcess execProcess; - execProcess.setProcessEnvironment(processEnv); execProcess.setProcessChannelMode(QProcess::MergedChannels); execProcess.start(cmd, arguments); if (!execProcess.waitForStarted()) diff --git a/Code/Tools/ProjectManager/Source/ProjectUtils.h b/Code/Tools/ProjectManager/Source/ProjectUtils.h index ee605b5117..d84b367d5b 100644 --- a/Code/Tools/ProjectManager/Source/ProjectUtils.h +++ b/Code/Tools/ProjectManager/Source/ProjectUtils.h @@ -47,7 +47,6 @@ namespace O3DE::ProjectManager AZ::Outcome ExecuteCommandResult( const QString& cmd, const QStringList& arguments, - const QProcessEnvironment& processEnv, int commandTimeoutSeconds = ProjectCommandLineTimeoutSeconds); /** @@ -61,10 +60,9 @@ namespace O3DE::ProjectManager AZ::Outcome ExecuteCommandResultModalDialog( const QString& cmd, const QStringList& arguments, - const QProcessEnvironment& processEnv, const QString& title); - AZ::Outcome GetCommandLineProcessEnvironment(); + AZ::Outcome SetupCommandLineProcessEnvironment(); AZ::Outcome GetProjectBuildPath(const QString& projectPath); AZ::Outcome OpenCMakeGUI(const QString& projectPath); AZ::Outcome RunGetPythonScript(const QString& enginePath); From 74e1ee1862aec8485245fd94870c842327ffbbaa Mon Sep 17 00:00:00 2001 From: AMZN-Phil Date: Sat, 20 Nov 2021 10:23:50 -0800 Subject: [PATCH 2/5] Fix non-Windows platforms Signed-off-by: AMZN-Phil --- .../Platform/Linux/ProjectUtils_linux.cpp | 5 ++--- .../Platform/Mac/ProjectUtils_mac.cpp | 15 +++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp b/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp index a7bd2dae08..f9a1906b8a 100644 --- a/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp +++ b/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp @@ -19,10 +19,9 @@ namespace O3DE::ProjectManager // The list of clang C/C++ compiler command lines to validate on the host Linux system const QStringList SupportedClangVersions = {"13", "12", "11", "10", "9", "8", "7", "6.0"}; - AZ::Outcome GetCommandLineProcessEnvironment() + AZ::Outcome SetupCommandLineProcessEnvironment() { - QProcessEnvironment currentEnvironment(QProcessEnvironment::systemEnvironment()); - return AZ::Success(currentEnvironment); + return AZ::Success(); } AZ::Outcome FindSupportedCompilerForPlatform() diff --git a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp index 62011bf04b..24a8fc1ff8 100644 --- a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp +++ b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp @@ -18,17 +18,20 @@ namespace O3DE::ProjectManager { namespace ProjectUtils { - AZ::Outcome GetCommandLineProcessEnvironment() + AZ::Outcome GetCommandLineProcessEnvironment() { // For CMake on Mac, if its installed through home-brew, then it will be installed // under /usr/local/bin, which may not be in the system PATH environment. // Add that path for the command line process so that it will be able to locate // a home-brew installed version of CMake - QProcessEnvironment currentEnvironment(QProcessEnvironment::systemEnvironment()); - QString pathValue = currentEnvironment.value("PATH"); - pathValue += ":/usr/local/bin"; - currentEnvironment.insert("PATH", pathValue); - return AZ::Success(currentEnvironment); + QString pathEnv = qEnvironmentVariable("PATH"); + if (!pathEnv.contains("/usr/local/bin")) + { + pathEnv += ":/usr/local/bin"; + qputenv("PATH", pathEnv.toStdString().c_str()); + } + + return AZ::Success(); } AZ::Outcome FindSupportedCompilerForPlatform() From def5b3a65d9863cb981197b2bcc2c34d5e478b76 Mon Sep 17 00:00:00 2001 From: AMZN-Phil Date: Sat, 20 Nov 2021 10:37:55 -0800 Subject: [PATCH 3/5] Fix additional left over references to QProcessEnvironment Signed-off-by: AMZN-Phil --- .../Linux/ProjectBuilderWorker_linux.cpp | 4 ++-- .../Platform/Linux/ProjectUtils_linux.cpp | 10 ++++------ .../Platform/Mac/ProjectBuilderWorker_mac.cpp | 6 ++---- .../Platform/Mac/ProjectUtils_mac.cpp | 18 +++++++++--------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Code/Tools/ProjectManager/Platform/Linux/ProjectBuilderWorker_linux.cpp b/Code/Tools/ProjectManager/Platform/Linux/ProjectBuilderWorker_linux.cpp index fdeaef93bb..5cade609d7 100644 --- a/Code/Tools/ProjectManager/Platform/Linux/ProjectBuilderWorker_linux.cpp +++ b/Code/Tools/ProjectManager/Platform/Linux/ProjectBuilderWorker_linux.cpp @@ -19,7 +19,7 @@ namespace O3DE::ProjectManager { // Attempt to use the Ninja build system if it is installed (described in the o3de documentation) if possible, // otherwise default to the the default for Linux (Unix Makefiles) - auto whichNinjaResult = ProjectUtils::ExecuteCommandResult("which", QStringList{"ninja"}, QProcessEnvironment::systemEnvironment()); + auto whichNinjaResult = ProjectUtils::ExecuteCommandResult("which", QStringList{"ninja"}); QString cmakeGenerator = (whichNinjaResult.IsSuccess()) ? "Ninja Multi-Config" : "Unix Makefiles"; bool compileProfileOnBuild = (whichNinjaResult.IsSuccess()); @@ -38,7 +38,7 @@ namespace O3DE::ProjectManager AZ::Outcome ProjectBuilderWorker::ConstructCmakeBuildCommandArguments() const { - auto whichNinjaResult = ProjectUtils::ExecuteCommandResult("which", QStringList{"ninja"}, QProcessEnvironment::systemEnvironment()); + auto whichNinjaResult = ProjectUtils::ExecuteCommandResult("which", QStringList{"ninja"}); bool compileProfileOnBuild = (whichNinjaResult.IsSuccess()); QString targetBuildPath = QDir(m_projectInfo.m_path).filePath(ProjectBuildPathPostfix); QString launcherTargetName = m_projectInfo.m_projectName + ".GameLauncher"; diff --git a/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp b/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp index f9a1906b8a..cb8ea843e5 100644 --- a/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp +++ b/Code/Tools/ProjectManager/Platform/Linux/ProjectUtils_linux.cpp @@ -27,7 +27,7 @@ namespace O3DE::ProjectManager AZ::Outcome FindSupportedCompilerForPlatform() { // Validate that cmake is installed and is in the command line - auto whichCMakeResult = ProjectUtils::ExecuteCommandResult("which", QStringList{ProjectCMakeCommand}, QProcessEnvironment::systemEnvironment()); + auto whichCMakeResult = ProjectUtils::ExecuteCommandResult("which", QStringList{ProjectCMakeCommand}); if (!whichCMakeResult.IsSuccess()) { return AZ::Failure(QObject::tr("CMake not found.

" @@ -38,8 +38,8 @@ namespace O3DE::ProjectManager // Look for the first compatible version of clang. The list below will contain the known clang compilers that have been tested for O3DE. for (const QString& supportClangVersion : SupportedClangVersions) { - auto whichClangResult = ProjectUtils::ExecuteCommandResult("which", QStringList{QString("clang-%1").arg(supportClangVersion)}, QProcessEnvironment::systemEnvironment()); - auto whichClangPPResult = ProjectUtils::ExecuteCommandResult("which", QStringList{QString("clang++-%1").arg(supportClangVersion)}, QProcessEnvironment::systemEnvironment()); + auto whichClangResult = ProjectUtils::ExecuteCommandResult("which", QStringList{QString("clang-%1").arg(supportClangVersion)}); + auto whichClangPPResult = ProjectUtils::ExecuteCommandResult("which", QStringList{QString("clang++-%1").arg(supportClangVersion)}); if (whichClangResult.IsSuccess() && whichClangPPResult.IsSuccess()) { return AZ::Success(QString("clang-%1").arg(supportClangVersion)); @@ -53,7 +53,7 @@ namespace O3DE::ProjectManager AZ::Outcome OpenCMakeGUI(const QString& projectPath) { - AZ::Outcome processEnvResult = GetCommandLineProcessEnvironment(); + AZ::Outcome processEnvResult = SetupCommandLineProcessEnvironment(); if (!processEnvResult.IsSuccess()) { return AZ::Failure(processEnvResult.GetError()); @@ -67,7 +67,6 @@ namespace O3DE::ProjectManager } QProcess process; - process.setProcessEnvironment(processEnvResult.GetValue()); // if the project build path is relative, it should be relative to the project path process.setWorkingDirectory(projectPath); @@ -87,7 +86,6 @@ namespace O3DE::ProjectManager return ExecuteCommandResultModalDialog( QString("%1/python/get_python.sh").arg(engineRoot), {}, - QProcessEnvironment::systemEnvironment(), QObject::tr("Running get_python script...")); } diff --git a/Code/Tools/ProjectManager/Platform/Mac/ProjectBuilderWorker_mac.cpp b/Code/Tools/ProjectManager/Platform/Mac/ProjectBuilderWorker_mac.cpp index ab412d84d8..2a8bbf4839 100644 --- a/Code/Tools/ProjectManager/Platform/Mac/ProjectBuilderWorker_mac.cpp +++ b/Code/Tools/ProjectManager/Platform/Mac/ProjectBuilderWorker_mac.cpp @@ -19,16 +19,14 @@ namespace O3DE::ProjectManager { AZ::Outcome QueryInstalledCmakeFullPath() { - auto environmentRequest = ProjectUtils::GetCommandLineProcessEnvironment(); + auto environmentRequest = ProjectUtils::SetupCommandLineProcessEnvironment(); if (!environmentRequest.IsSuccess()) { return AZ::Failure(environmentRequest.GetError()); } - auto currentEnvironment = environmentRequest.GetValue(); auto queryCmakeInstalled = ProjectUtils::ExecuteCommandResult("which", - QStringList{ProjectCMakeCommand}, - currentEnvironment); + QStringList{ProjectCMakeCommand}); if (!queryCmakeInstalled.IsSuccess()) { return AZ::Failure(QObject::tr("Unable to detect CMake on this host.")); diff --git a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp index 24a8fc1ff8..430e8974b7 100644 --- a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp +++ b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp @@ -18,7 +18,7 @@ namespace O3DE::ProjectManager { namespace ProjectUtils { - AZ::Outcome GetCommandLineProcessEnvironment() + AZ::Outcome SetupCommandLineProcessEnvironment() { // For CMake on Mac, if its installed through home-brew, then it will be installed // under /usr/local/bin, which may not be in the system PATH environment. @@ -36,13 +36,14 @@ namespace O3DE::ProjectManager AZ::Outcome FindSupportedCompilerForPlatform() { - QProcessEnvironment currentEnvironment(QProcessEnvironment::systemEnvironment()); - QString pathValue = currentEnvironment.value("PATH"); - pathValue += ":/usr/local/bin"; - currentEnvironment.insert("PATH", pathValue); + AZ::Outcome processEnvResult = SetupCommandLineProcessEnvironment(); + if (!processEnvResult.IsSuccess()) + { + return AZ::Failure(processEnvResult.GetError()); + } // Validate that we have cmake installed first - auto queryCmakeInstalled = ExecuteCommandResult("which", QStringList{ProjectCMakeCommand}, currentEnvironment); + auto queryCmakeInstalled = ExecuteCommandResult("which", QStringList{ProjectCMakeCommand}); if (!queryCmakeInstalled.IsSuccess()) { return AZ::Failure(QObject::tr("Unable to detect CMake on this host.")); @@ -50,7 +51,7 @@ namespace O3DE::ProjectManager QString cmakeInstalledPath = queryCmakeInstalled.GetValue().split("\n")[0]; // Query the version of the installed cmake - auto queryCmakeVersionQuery = ExecuteCommandResult(cmakeInstalledPath, QStringList{"-version"}, currentEnvironment); + auto queryCmakeVersionQuery = ExecuteCommandResult(cmakeInstalledPath, QStringList{"-version"}); if (!queryCmakeVersionQuery.IsSuccess()) { return AZ::Failure(QObject::tr("Unable to determine the version of CMake on this host.")); @@ -58,7 +59,7 @@ namespace O3DE::ProjectManager AZ_TracePrintf("Project Manager", "Cmake version %s detected.", queryCmakeVersionQuery.GetValue().split("\n")[0].toUtf8().constData()); // Query for the version of xcodebuild (if installed) - auto queryXcodeBuildVersion = ExecuteCommandResult("xcodebuild", QStringList{"-version"}, currentEnvironment); + auto queryXcodeBuildVersion = ExecuteCommandResult("xcodebuild", QStringList{"-version"}); if (!queryCmakeInstalled.IsSuccess()) { return AZ::Failure(QObject::tr("Unable to detect XCodeBuilder on this host.")); @@ -107,7 +108,6 @@ namespace O3DE::ProjectManager return ExecuteCommandResultModalDialog( QString("%1/python/get_python.sh").arg(engineRoot), {}, - QProcessEnvironment::systemEnvironment(), QObject::tr("Running get_python script...")); } From c2145a63877e0606e0dd534b8fd4da01cdc00256 Mon Sep 17 00:00:00 2001 From: AMZN-Phil Date: Mon, 22 Nov 2021 08:31:12 -0800 Subject: [PATCH 4/5] Use QStringList to avoid false matches against a partial path Signed-off-by: AMZN-Phil --- Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp | 3 ++- .../ProjectManager/Platform/Windows/ProjectUtils_windows.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp index 430e8974b7..0c232d44d1 100644 --- a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp +++ b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp @@ -25,7 +25,8 @@ namespace O3DE::ProjectManager // Add that path for the command line process so that it will be able to locate // a home-brew installed version of CMake QString pathEnv = qEnvironmentVariable("PATH"); - if (!pathEnv.contains("/usr/local/bin")) + QStringList pathEnvList = pathEnv.split(":"); + if (!pathEnvList.contains("/usr/local/bin")) { pathEnv += ":/usr/local/bin"; qputenv("PATH", pathEnv.toStdString().c_str()); diff --git a/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp b/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp index 365aac7069..92863b955c 100644 --- a/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp +++ b/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp @@ -37,7 +37,8 @@ namespace O3DE::ProjectManager QDir cmakePath(engineInfo.m_path); cmakePath.cd("cmake/runtime/bin"); QString pathEnv = qEnvironmentVariable("Path"); - if (!pathEnv.contains(cmakePath.path())) + QStringList pathEnvList = pathEnv.split(";"); + if (!pathEnvList.contains(cmakePath.path())) { pathEnv += ";" + cmakePath.path(); qputenv("Path", pathEnv.toStdString().c_str()); From d958502f2c5c2cfa52b11dcf6478a875c14ccb1f Mon Sep 17 00:00:00 2001 From: AMZN-Phil Date: Mon, 22 Nov 2021 09:26:34 -0800 Subject: [PATCH 5/5] Check return value of qputenv Signed-off-by: AMZN-Phil --- Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp | 5 ++++- .../ProjectManager/Platform/Windows/ProjectUtils_windows.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp index 0c232d44d1..07b08924f1 100644 --- a/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp +++ b/Code/Tools/ProjectManager/Platform/Mac/ProjectUtils_mac.cpp @@ -29,7 +29,10 @@ namespace O3DE::ProjectManager if (!pathEnvList.contains("/usr/local/bin")) { pathEnv += ":/usr/local/bin"; - qputenv("PATH", pathEnv.toStdString().c_str()); + if (!qputenv("PATH", pathEnv.toStdString().c_str())) + { + return AZ::Failure(QObject::tr("Failed to set PATH environment variable")); + } } return AZ::Success(); diff --git a/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp b/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp index 92863b955c..b8cfe65b1e 100644 --- a/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp +++ b/Code/Tools/ProjectManager/Platform/Windows/ProjectUtils_windows.cpp @@ -41,7 +41,10 @@ namespace O3DE::ProjectManager if (!pathEnvList.contains(cmakePath.path())) { pathEnv += ";" + cmakePath.path(); - qputenv("Path", pathEnv.toStdString().c_str()); + if (!qputenv("Path", pathEnv.toStdString().c_str())) + { + return AZ::Failure(QObject::tr("Failed to set Path environment variable")); + } } return AZ::Success();