Some improvements to init_process() function.

This commit is contained in:
LoRd_MuldeR 2016-10-02 17:32:40 +02:00
parent 1f7d2131e8
commit 37522d4c15
2 changed files with 10 additions and 4 deletions

View File

@ -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);

View File

@ -37,6 +37,7 @@
#include <QProcess>
#include <QTextCodec>
#include <QPair>
#include <QListIterator>
//CRT
#include <cstdlib>
@ -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<QString> iter(*extraPaths);
iter.toBack();
while (iter.hasPrevious())
{
prependToPath(env, QDir::toNativeSeparators(iter.previous()));
}
}
//Setup QPorcess object