aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2021-07-07 10:33:28 +0200
committerEike Ziller <eike.ziller@qt.io>2021-07-07 08:45:59 +0000
commit0df677f7ace7cd4a8e6dc7424351e71809737fc2 (patch)
tree41c140876bc3cce3583cfc089d178fecec3ae1a8
parent434c33f4ee7cd00612fb893354d5c9655dcfb6cc (diff)
AutoTest: Guard simultaneous access to header cache
It is accessed from multiple threads at once. Guard with mutex to avoid crashes. Amends 64ce2a6f4374012b37b420dc0aaa6ea406bf7168 Change-Id: I5048e5fcdb27b2492656b302775378829b6da013 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/autotest/itestparser.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/plugins/autotest/itestparser.cpp b/src/plugins/autotest/itestparser.cpp
index fd021df42e..b11393b952 100644
--- a/src/plugins/autotest/itestparser.cpp
+++ b/src/plugins/autotest/itestparser.cpp
@@ -37,6 +37,7 @@ namespace Autotest {
using LookupInfo = QPair<QString, QString>;
static QHash<LookupInfo, bool> s_pchLookupCache;
+Q_GLOBAL_STATIC(QMutex, s_cacheMutex);
CppParser::CppParser(ITestFramework *framework)
: ITestParser(framework)
@@ -96,6 +97,7 @@ bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
}
return it.value();
};
+ QMutexLocker l(s_cacheMutex());
return Utils::anyOf(precompiledHeaders, headerContains);
}
@@ -127,6 +129,7 @@ void CppParser::release()
{
m_cppSnapshot = CPlusPlus::Snapshot();
m_workingCopy = CppTools::WorkingCopy();
+ QMutexLocker l(s_cacheMutex());
s_pchLookupCache.clear();
}