From 727523ffc9df91f5a21955e10a85148906d2d142 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 12 Nov 2015 14:02:20 +0100 Subject: [PATCH] SessionManager: Improve handling of unconfigured projects in sessions Force Project Mode if the startup project is in need to be configured after a session is loaded. Task-number: QTCREATORBUG-15228 Change-Id: I625a9485c5233ff717be20fd2c14c85a3b9275e3 Reviewed-by: Eike Ziller Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/session.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 39c6cc52a2f..8e9bcbc1bb0 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -1062,6 +1062,8 @@ bool SessionManager::loadSession(const QString &session) // retrieve all values before the following code could change them again Id modeId = Id::fromSetting(value(QLatin1String("ActiveMode"))); + if (!modeId.isValid()) + modeId = Id(Core::Constants::MODE_EDIT); QColor c = QColor(reader.restoreValue(QLatin1String("Color")).toString()); if (c.isValid()) @@ -1083,9 +1085,10 @@ bool SessionManager::loadSession(const QString &session) d->m_future.reportFinished(); d->m_future = QFutureInterface(); - // restore the active mode - if (!modeId.isValid()) - modeId = Id(Core::Constants::MODE_EDIT); + // Fall back to Project mode if the startup project is unconfigured and + // use the mode saved in the session otherwise + if (d->m_startupProject && d->m_startupProject->needsConfiguration()) + modeId = Id(Constants::MODE_SESSION); ModeManager::activateMode(modeId); ModeManager::setFocusToCurrentMode();