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 <oswald.buddenhagen@theqtcompany.com> (cherry picked from qtcreator/dedcd25924743e494055c1e0195aeef0f3983a1d) (cherry picked from qtcreator/b335b2a083e456e2b44b1e9454a0f4cd41e2a397) (cherry picked from qtcreator/a027cbcd7051c634a51b6029dcb8a5b4bfe8b046) Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
69032adda0
commit
e59d39c6fd
@ -64,6 +64,18 @@ void ProFileCache::discardFile(const QString &fileName)
|
|||||||
#endif
|
#endif
|
||||||
QHash<QString, Entry>::Iterator it = parsed_files.find(fileName);
|
QHash<QString, Entry>::Iterator it = parsed_files.find(fileName);
|
||||||
if (it != parsed_files.end()) {
|
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)
|
if (it->pro)
|
||||||
it->pro->deref();
|
it->pro->deref();
|
||||||
parsed_files.erase(it);
|
parsed_files.erase(it);
|
||||||
@ -80,6 +92,18 @@ void ProFileCache::discardFiles(const QString &prefix)
|
|||||||
end = parsed_files.end();
|
end = parsed_files.end();
|
||||||
while (it != end)
|
while (it != end)
|
||||||
if (it.key().startsWith(prefix)) {
|
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)
|
if (it->pro)
|
||||||
it->pro->deref();
|
it->pro->deref();
|
||||||
it = parsed_files.erase(it);
|
it = parsed_files.erase(it);
|
||||||
@ -88,7 +112,6 @@ void ProFileCache::discardFiles(const QString &prefix)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////// Parser ///////////
|
////////// Parser ///////////
|
||||||
|
|
||||||
#define fL1S(s) QString::fromLatin1(s)
|
#define fL1S(s) QString::fromLatin1(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user