CppEditor: Fix a crash on concurrent access to knownNames

Fixes: QTCREATORBUG-31569
Change-Id: Ic7248facf78c7778aae50a598c01c77e6b2897c1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2024-09-17 14:14:41 +02:00
parent 249b9f148f
commit e986dc8938

View File

@@ -146,22 +146,22 @@ void moveCursorToStartOfIdentifier(QTextCursor *tc)
static bool isOwnershipRAIIName(const QString &name) static bool isOwnershipRAIIName(const QString &name)
{ {
static QSet<QString> knownNames; static const QSet<QString> knownNames {
if (knownNames.isEmpty()) {
// Qt // Qt
knownNames.insert(QLatin1String("QScopedPointer")); "QMutexLocker",
knownNames.insert(QLatin1String("QScopedArrayPointer")); "QReadLocker",
knownNames.insert(QLatin1String("QMutexLocker")); "QScopedArrayPointer",
knownNames.insert(QLatin1String("QReadLocker")); "QScopedPointer",
knownNames.insert(QLatin1String("QWriteLocker")); "QWriteLocker",
// Standard C++
knownNames.insert(QLatin1String("auto_ptr"));
knownNames.insert(QLatin1String("unique_ptr"));
// Boost
knownNames.insert(QLatin1String("scoped_ptr"));
knownNames.insert(QLatin1String("scoped_array"));
}
// Standard C++
"auto_ptr",
"unique_ptr",
// Boost
"scoped_array",
"scoped_ptr",
};
return knownNames.contains(name); return knownNames.contains(name);
} }