ClassView: Clear the documentCache, too, when reset was requested

Otherwise when we switch session we still keep
the data about the old session in the cache, which is pointless.
Protect clearing both caches with both mutexes, so it comes
atomically.

Task-number: QTCREATORBUG-25317
Change-Id: Ic5bc7ae2b8640e9290024e00c394ca9608f88da9
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-02-12 16:12:15 +01:00
parent 1364630d1f
commit cc6df4e707

View File

@@ -549,12 +549,10 @@ void Parser::removeFiles(const QStringList &fileList)
void Parser::resetData(const CPlusPlus::Snapshot &snapshot) void Parser::resetData(const CPlusPlus::Snapshot &snapshot)
{ {
{ {
QWriteLocker locker(&d->m_projectLock); QWriteLocker projectLocker(&d->m_projectLock);
QWriteLocker documentLocker(&d->m_documentLock);
d->m_projectCache.clear(); d->m_projectCache.clear();
} d->m_documentCache.clear();
{
QWriteLocker locker(&d->m_documentLock);
for (auto it = snapshot.begin(); it != snapshot.end(); ++it) for (auto it = snapshot.begin(); it != snapshot.end(); ++it)
d->m_documentCache[it.key().toString()].document = it.value(); d->m_documentCache[it.key().toString()].document = it.value();
} }