Commit aa61af14 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

make the evaluator (even more) thread-safe

the async re-parsing code breaks the assumption that project
parsing only ever starts with a single non-concurrent evaluation
(of the top-level project file), so the population of the base
values in the shared ProFileOption was happily causing crashes.

Reviewed-by: dt
Task-number: QTCREATORBUG-1569
parent 8a07e6a3
......@@ -96,7 +96,7 @@ FORMS += makestep.ui \
wizards/targetsetuppage.ui
RESOURCES += qt4projectmanager.qrc \
wizards/wizards.qrc
DEFINES += PROPARSER_THREAD_SAFE
DEFINES += PROPARSER_THREAD_SAFE PROEVALUATOR_THREAD_SAFE
include(../../shared/proparser/proparser.pri)
include(qt-s60/qt-s60.pri)
include(qt-maemo/qt-maemo.pri)
......
......@@ -161,6 +161,10 @@ ProFileOption::ProFileOption()
#endif
cache = 0;
#ifdef PROEVALUATOR_THREAD_SAFE
base_inProgress = false;
#endif
}
ProFileOption::~ProFileOption()
......@@ -1270,7 +1274,21 @@ ProItem::ProItemReturn ProFileEvaluator::Private::visitProFile(ProFile *pro)
if (m_parsePreAndPostFiles) {
#ifdef PROEVALUATOR_THREAD_SAFE
{
QMutexLocker locker(&m_option->mutex);
if (m_option->base_inProgress) {
QThreadPool::globalInstance()->releaseThread();
m_option->cond.wait(&m_option->mutex);
QThreadPool::globalInstance()->reserveThread();
} else
#endif
if (m_option->base_valuemap.isEmpty()) {
#ifdef PROEVALUATOR_THREAD_SAFE
m_option->base_inProgress = true;
locker.unlock();
#endif
// ### init QMAKE_QMAKE, QMAKE_SH
// ### init QMAKE_EXT_{C,H,CPP,OBJ}
// ### init TEMPLATE_PREFIX
......@@ -1377,7 +1395,16 @@ ProItem::ProItemReturn ProFileEvaluator::Private::visitProFile(ProFile *pro)
evaluateFeatureFile(QLatin1String("default_pre.prf"),
&m_option->base_valuemap, &m_option->base_functions);
#ifdef PROEVALUATOR_THREAD_SAFE
locker.relock();
m_option->base_inProgress = false;
m_option->cond.wakeAll();
#endif
}
#ifdef PROEVALUATOR_THREAD_SAFE
}
#endif
m_valuemapStack.top() = m_option->base_valuemap;
......
......@@ -182,6 +182,11 @@ struct ProFileOption
ProFileEvaluator::FunctionDefs base_functions;
QStringList feature_roots;
QString qmakespec_name;
#ifdef PROEVALUATOR_THREAD_SAFE
QMutex mutex;
QWaitCondition cond;
bool base_inProgress;
#endif
};
QT_END_NAMESPACE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment