forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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('"'));
|
||||
|
Reference in New Issue
Block a user