forked from qt-creator/qt-creator
Fix deadlock in .pro file evaluation.
We used to indicate that the cache for a file is up to date by having a Entry with ent->locker == 0. But we first wake up all threads and only after all the threads who waited for that parse to complete we set ent->locker to zero. Thus a different thread could get the impression that it needs to wait for the parse thread, yet get no wake up. We need a different flag to indicate that we are actually already done parsing and the cache can simply be used instead of waiting for a wake up. Reviewed-By: ossi
This commit is contained in:
@@ -3031,7 +3031,7 @@ ProFile *ProFileEvaluator::Private::parsedProFile(const QString &fileName, bool
|
||||
if (it != m_option->cache->parsed_files.end()) {
|
||||
ent = &*it;
|
||||
#ifdef PROPARSER_THREAD_SAFE
|
||||
if (ent->locker) {
|
||||
if (ent->locker && !ent->locker->done) {
|
||||
++ent->locker->waiters;
|
||||
QThreadPool::globalInstance()->releaseThread();
|
||||
ent->locker->cond.wait(locker.mutex());
|
||||
@@ -3061,6 +3061,7 @@ ProFile *ProFileEvaluator::Private::parsedProFile(const QString &fileName, bool
|
||||
#ifdef PROPARSER_THREAD_SAFE
|
||||
locker.relock();
|
||||
if (ent->locker->waiters) {
|
||||
ent->locker->done = true;
|
||||
ent->locker->cond.wakeAll();
|
||||
} else {
|
||||
delete ent->locker;
|
||||
|
||||
Reference in New Issue
Block a user