Fix "Projects mode" looking broken if the startup project is "wrong"

E.g. this could happen if a session with two projects is opened, where
the startup project no longer exists.

Change-Id: I1c60bacb62b5f39f7830a3bc30e3aa388a825884
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Daniel Teske
2012-05-08 17:41:08 +02:00
parent 5692c68154
commit d51edeaf51

View File

@@ -748,15 +748,17 @@ void SessionManager::restoreStartupProject(const Utils::PersistentSettingsReader
{ {
const QString startupProject = reader.restoreValue(QLatin1String("StartupProject")).toString(); const QString startupProject = reader.restoreValue(QLatin1String("StartupProject")).toString();
if (!startupProject.isEmpty()) { if (!startupProject.isEmpty()) {
const QString startupProjectPath = startupProject;
foreach (Project *pro, m_projects) { foreach (Project *pro, m_projects) {
if (QDir::cleanPath(pro->document()->fileName()) == startupProjectPath) { if (QDir::cleanPath(pro->document()->fileName()) == startupProject) {
setStartupProject(pro); setStartupProject(pro);
break; break;
} }
} }
if (!m_startupProject) }
qWarning() << "Could not find startup project" << startupProjectPath; if (!m_startupProject) {
qWarning() << "Could not find startup project" << startupProject;
if (!projects().isEmpty())
setStartupProject(projects().first());
} }
} }