From 37522d4c157099ae1b335908ddbd4896b441cf06 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 2 Oct 2016 17:32:40 +0200 Subject: [PATCH] Some improvements to init_process() function. --- include/MUtils/Global.h | 2 +- src/Global.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/MUtils/Global.h b/include/MUtils/Global.h index e25957d..3bd3a5a 100644 --- a/include/MUtils/Global.h +++ b/include/MUtils/Global.h @@ -76,7 +76,7 @@ namespace MUtils MUTILS_API const QString& temp_folder(void); //Process Utils - MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true, const QString &extraPath = QString()); + MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true, const QStringList *const extraPaths = NULL); //Random MUTILS_API void seed_rand(void); diff --git a/src/Global.cpp b/src/Global.cpp index 26fd3bf..0c6260a 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -37,6 +37,7 @@ #include #include #include +#include //CRT #include @@ -391,7 +392,7 @@ static void prependToPath(QProcessEnvironment &env, const QString &value) env.insert(PATH, path.isEmpty() ? value : QString("%1;%2").arg(value, path)); } -void MUtils::init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir, const QString &extraPath) +void MUtils::init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir, const QStringList *const extraPaths) { //Environment variable names static const char *const s_envvar_names_temp[] = @@ -427,9 +428,14 @@ void MUtils::init_process(QProcess &process, const QString &wokringDir, const bo //Setup PATH variable prependToPath(env, tempDir); - if (!extraPath.isEmpty()) + if (extraPaths && (!extraPaths->isEmpty())) { - prependToPath(env, QDir::toNativeSeparators(extraPath)); + QListIterator iter(*extraPaths); + iter.toBack(); + while (iter.hasPrevious()) + { + prependToPath(env, QDir::toNativeSeparators(iter.previous())); + } } //Setup QPorcess object