check for QMap::find / end usage when QReadLocker is used to protect concurent access
This piece of code:
// m_fileToProjectParts is a QMap
{
QReadLocker locker(&d->m_projectLock);
auto it = d->m_fileToProjectParts.find(fileName);
if (it != d->m_fileToProjectParts.end())
return it.value();
}
has a bug because QMap::find
and QMap::end
would call QMap::detach
and might get iterators that will no longer be valid.
See https://codereview.qt-project.org/c/qt-creator/qt-creator/+/516392 which fixes the issue by using QMap::constFind
and QMap::constEnd
.