forked from qt-creator/qt-creator
lock baseEnv in cache()
as we modify the environment, it must be properly locked. this implies that initFrom() also needs to be called with a lock. Task-number: QTCREATORBUG-9835 Change-Id: I48bae9af9adaa0518e5a9db0ba08ff057ae14f9f Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
@@ -1302,47 +1302,45 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
|
||||
QMakeBaseEnv *baseEnv = *baseEnvPtr;
|
||||
|
||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||
{
|
||||
QMutexLocker locker(&baseEnv->mutex);
|
||||
m_option->mutex.unlock();
|
||||
if (baseEnv->inProgress) {
|
||||
QThreadPool::globalInstance()->releaseThread();
|
||||
baseEnv->cond.wait(&baseEnv->mutex);
|
||||
QThreadPool::globalInstance()->reserveThread();
|
||||
if (!baseEnv->isOk)
|
||||
return ReturnFalse;
|
||||
} else
|
||||
QMutexLocker locker(&baseEnv->mutex);
|
||||
m_option->mutex.unlock();
|
||||
if (baseEnv->inProgress) {
|
||||
QThreadPool::globalInstance()->releaseThread();
|
||||
baseEnv->cond.wait(&baseEnv->mutex);
|
||||
QThreadPool::globalInstance()->reserveThread();
|
||||
if (!baseEnv->isOk)
|
||||
return ReturnFalse;
|
||||
} else
|
||||
#endif
|
||||
if (!baseEnv->evaluator) {
|
||||
if (!baseEnv->evaluator) {
|
||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||
baseEnv->inProgress = true;
|
||||
locker.unlock();
|
||||
baseEnv->inProgress = true;
|
||||
locker.unlock();
|
||||
#endif
|
||||
|
||||
QMakeEvaluator *baseEval = new QMakeEvaluator(m_option, m_parser, m_vfs, m_handler);
|
||||
baseEnv->evaluator = baseEval;
|
||||
baseEval->m_superfile = m_superfile;
|
||||
baseEval->m_conffile = m_conffile;
|
||||
baseEval->m_cachefile = m_cachefile;
|
||||
baseEval->m_sourceRoot = m_sourceRoot;
|
||||
baseEval->m_buildRoot = m_buildRoot;
|
||||
baseEval->m_hostBuild = m_hostBuild;
|
||||
bool ok = baseEval->loadSpec();
|
||||
QMakeEvaluator *baseEval = new QMakeEvaluator(m_option, m_parser, m_vfs, m_handler);
|
||||
baseEnv->evaluator = baseEval;
|
||||
baseEval->m_superfile = m_superfile;
|
||||
baseEval->m_conffile = m_conffile;
|
||||
baseEval->m_cachefile = m_cachefile;
|
||||
baseEval->m_sourceRoot = m_sourceRoot;
|
||||
baseEval->m_buildRoot = m_buildRoot;
|
||||
baseEval->m_hostBuild = m_hostBuild;
|
||||
bool ok = baseEval->loadSpec();
|
||||
|
||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||
locker.relock();
|
||||
baseEnv->isOk = ok;
|
||||
baseEnv->inProgress = false;
|
||||
baseEnv->cond.wakeAll();
|
||||
locker.relock();
|
||||
baseEnv->isOk = ok;
|
||||
baseEnv->inProgress = false;
|
||||
baseEnv->cond.wakeAll();
|
||||
#endif
|
||||
|
||||
if (!ok)
|
||||
return ReturnFalse;
|
||||
}
|
||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||
else if (!baseEnv->isOk)
|
||||
if (!ok)
|
||||
return ReturnFalse;
|
||||
}
|
||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||
else if (!baseEnv->isOk)
|
||||
return ReturnFalse;
|
||||
#endif
|
||||
|
||||
initFrom(*baseEnv->evaluator);
|
||||
|
||||
Reference in New Issue
Block a user