From e59d39c6fd96bff7466cf655f4b67e83edf50d6e Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Thu, 16 Jul 2015 17:42:08 +0200 Subject: [PATCH] QmakeProject: Fix crash on updating sources ProFileCacheManager::discardFile(s) may remove an entry from the ProfileCache only when it is unused (which is the case iff ent->locker is zero). Change-Id: I9df2079087af6bd0d35dd121db6222e8a6ec9389 Task-number: QTCREATORBUG-14730 Reviewed-by: Oswald Buddenhagen (cherry picked from qtcreator/dedcd25924743e494055c1e0195aeef0f3983a1d) (cherry picked from qtcreator/b335b2a083e456e2b44b1e9454a0f4cd41e2a397) (cherry picked from qtcreator/a027cbcd7051c634a51b6029dcb8a5b4bfe8b046) Reviewed-by: Joerg Bornemann --- qmake/library/qmakeparser.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/qmake/library/qmakeparser.cpp b/qmake/library/qmakeparser.cpp index 3fd7957bc0f..95a072392e4 100644 --- a/qmake/library/qmakeparser.cpp +++ b/qmake/library/qmakeparser.cpp @@ -64,6 +64,18 @@ void ProFileCache::discardFile(const QString &fileName) #endif QHash::Iterator it = parsed_files.find(fileName); if (it != parsed_files.end()) { +#ifdef PROPARSER_THREAD_SAFE + if (it->locker) { + if (!it->locker->done) { + ++it->locker->waiters; + it->locker->cond.wait(&mutex); + if (!--it->locker->waiters) { + delete it->locker; + it->locker = 0; + } + } + } +#endif if (it->pro) it->pro->deref(); parsed_files.erase(it); @@ -80,6 +92,18 @@ void ProFileCache::discardFiles(const QString &prefix) end = parsed_files.end(); while (it != end) if (it.key().startsWith(prefix)) { +#ifdef PROPARSER_THREAD_SAFE + if (it->locker) { + if (!it->locker->done) { + ++it->locker->waiters; + it->locker->cond.wait(&mutex); + if (!--it->locker->waiters) { + delete it->locker; + it->locker = 0; + } + } + } +#endif if (it->pro) it->pro->deref(); it = parsed_files.erase(it); @@ -88,7 +112,6 @@ void ProFileCache::discardFiles(const QString &prefix) } } - ////////// Parser /////////// #define fL1S(s) QString::fromLatin1(s)