diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-09-23 15:00:33 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-09-28 09:58:00 +0000 |
commit | 2d1805a378d481f8238d6b7ba316495901f298f8 (patch) | |
tree | 152bc8fad1ee53a8d8ec47a90f2da5121cc0d3ca /src | |
parent | 4b8635052f26360204ca589bc7536d77227a526d (diff) |
ProParser: Fix crash when starting a QProcess
QProcess modifies the internals of its QProcessEnvironment object in a
manner that is not thread-safe.
We therefore force a detach, so each QProcess instance gets its own
QProcessEnvironment.
Fixes: QTCREATORBUG-23504
Change-Id: I7fc1fda5e7bc11ac4e9a59596a5bdb0ac420a315
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/proparser/qmakebuiltins.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/shared/proparser/qmakebuiltins.cpp b/src/shared/proparser/qmakebuiltins.cpp index bdd6ab6a6c..b498ecdb47 100644 --- a/src/shared/proparser/qmakebuiltins.cpp +++ b/src/shared/proparser/qmakebuiltins.cpp @@ -459,8 +459,18 @@ void QMakeEvaluator::runProcess(QProcess *proc, const QString &command) const { proc->setWorkingDirectory(currentDirectory()); # ifdef PROEVALUATOR_SETENV - if (!m_option->environment.isEmpty()) - proc->setProcessEnvironment(m_option->environment); + if (!m_option->environment.isEmpty()) { + QProcessEnvironment env = m_option->environment; + static const QString dummyVar = "__qtc_dummy"; + static const QString notSetValue = "not set"; + const QString oldValue = env.value(dummyVar, notSetValue); // Just in case. + env.insert(dummyVar, "QTCREATORBUG-23504"); // Force detach. + if (oldValue == notSetValue) + env.remove(dummyVar); + else + env.insert(dummyVar, oldValue); + proc->setProcessEnvironment(env); + } # endif # ifdef Q_OS_WIN proc->setNativeArguments(QLatin1String("/v:off /s /c \"") + command + QLatin1Char('"')); |