From 6e154b305579b0839003865913e12d18a9d733b4 Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Thu, 29 Oct 2009 14:07:22 +0100 Subject: [PATCH] Don't crash if the restored default version index is out of range --- .../qt4projectmanager/qtversionmanager.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 5774b8dff3f..f28ec89eb01 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -141,6 +141,23 @@ QtVersionManager::QtVersionManager() writeVersionsIntoSettings(); updateDocumentation(); + + if (m_defaultVersion > m_versions.size() || m_defaultVersion < 0) { + // Invalid default version, correct that... + for(int i = 0; i < m_versions.size(); ++i) { + QtVersion *version = m_versions.at(i); + if (version->isAutodetected() && version->autodetectionSource() == PATH_AUTODETECTION_SOURCE && version->isValid()) { + m_defaultVersion = i; + break; + } + } + } + + if (m_defaultVersion > m_versions.size() || m_defaultVersion < 0) { + // Still invalid? Use the first one + m_defaultVersion = 0; + } + // cannot call from ctor, needs to get connected extenernally first QTimer::singleShot(0, this, SLOT(updateExamples())); } -- GitLab