diff options
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r-- | src/corelib/io/qprocess_win.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 6dd431eb47..329d1842f0 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -38,6 +38,7 @@ ** ****************************************************************************/ +//#define QPROCESS_DEBUG #include "qprocess.h" #include "qprocess_p.h" #include "qwindowspipereader_p.h" @@ -61,7 +62,29 @@ QT_BEGIN_NAMESPACE -//#define QPROCESS_DEBUG +QProcessEnvironment QProcessEnvironment::systemEnvironment() +{ + QProcessEnvironment env; + // Calls to setenv() affect the low-level environment as well. + // This is not the case the other way round. + if (wchar_t *envStrings = GetEnvironmentStringsW()) { + for (const wchar_t *entry = envStrings; *entry; ) { + const int entryLen = int(wcslen(entry)); + // + 1 to permit magic cmd variable names starting with = + if (const wchar_t *equal = wcschr(entry + 1, L'=')) { + int nameLen = equal - entry; + QString name = QString::fromWCharArray(entry, nameLen); + QString value = QString::fromWCharArray(equal + 1, entryLen - nameLen - 1); + env.d->hash.insert(QProcessEnvironmentPrivate::Key(name), value); + } + entry += entryLen + 1; + } + FreeEnvironmentStringsW(envStrings); + } + return env; +} + +#if QT_CONFIG(process) static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe) { @@ -367,28 +390,6 @@ static QString qt_create_commandline(const QString &program, const QStringList & return args; } -QProcessEnvironment QProcessEnvironment::systemEnvironment() -{ - QProcessEnvironment env; - // Calls to setenv() affect the low-level environment as well. - // This is not the case the other way round. - if (wchar_t *envStrings = GetEnvironmentStringsW()) { - for (const wchar_t *entry = envStrings; *entry; ) { - const int entryLen = int(wcslen(entry)); - // + 1 to permit magic cmd variable names starting with = - if (const wchar_t *equal = wcschr(entry + 1, L'=')) { - int nameLen = equal - entry; - QString name = QString::fromWCharArray(entry, nameLen); - QString value = QString::fromWCharArray(equal + 1, entryLen - nameLen - 1); - env.d->hash.insert(QProcessEnvironmentPrivate::Key(name), value); - } - entry += entryLen + 1; - } - FreeEnvironmentStringsW(envStrings); - } - return env; -} - static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Hash &environment) { QByteArray envlist; @@ -890,4 +891,6 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a return success; } +#endif // QT_CONFIG(process) + QT_END_NAMESPACE |