Fix crash in QtVersionManager

Introduced in 9c2568b8e8
Range-based for loops that modify the original container must
work on a copy.

Change-Id: Ib917014ab259c20b282cdc85e7ca6583f7844de5
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Eike Ziller
2019-10-21 16:29:28 +02:00
committed by Orgad Shaneh
parent b3b813c13c
commit 78e5a8a80a

View File

@@ -293,7 +293,8 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
} }
// First try to find a existing Qt version to update // First try to find a existing Qt version to update
bool restored = false; bool restored = false;
for (BaseQtVersion *v : qAsConst(m_versions)) { const VersionMap versionsCopy = m_versions; // m_versions is modified in loop
for (BaseQtVersion *v : versionsCopy) {
if (v->autodetectionSource() == autoDetectionSource) { if (v->autodetectionSource() == autoDetectionSource) {
id = v->uniqueId(); id = v->uniqueId();
if (debug) if (debug)
@@ -339,7 +340,8 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
qDebug() << ""; qDebug() << "";
} }
} }
for (BaseQtVersion *qtVersion : qAsConst(m_versions)) { const VersionMap versionsCopy = m_versions; // m_versions is modified in loop
for (BaseQtVersion *qtVersion : versionsCopy) {
if (qtVersion->autodetectionSource().startsWith("SDK.")) { if (qtVersion->autodetectionSource().startsWith("SDK.")) {
if (!sdkVersions.contains(qtVersion->autodetectionSource())) { if (!sdkVersions.contains(qtVersion->autodetectionSource())) {
if (debug) if (debug)