diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index b94110d871d..08f9a0eb795 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2031,8 +2031,12 @@ void ProjectExplorerPluginPrivate::savePersistentSettings() } QSettings *s = ICore::settings(); - if (!SessionManager::isDefaultVirgin()) - s->setValue(QLatin1String("ProjectExplorer/StartupSession"), SessionManager::activeSession()); + if (SessionManager::isDefaultVirgin()) { + s->remove(Constants::STARTUPSESSION_KEY); + } else { + s->setValue(Constants::STARTUPSESSION_KEY, SessionManager::activeSession()); + s->setValue(Constants::LASTSESSION_KEY, SessionManager::activeSession()); + } s->remove(QLatin1String("ProjectExplorer/RecentProjects/Files")); QStringList fileNames; @@ -2217,10 +2221,10 @@ void ProjectExplorerPluginPrivate::currentModeChanged(Id mode, Id oldMode) void ProjectExplorerPluginPrivate::determineSessionToRestoreAtStartup() { // Process command line arguments first: - if (m_instance->pluginSpec()->arguments().contains(QLatin1String("-lastsession"))) - m_sessionToRestoreAtStartup = SessionManager::lastSession(); + const bool lastSessionArg = m_instance->pluginSpec()->arguments().contains("-lastsession"); + m_sessionToRestoreAtStartup = lastSessionArg ? SessionManager::startupSession() : QString(); QStringList arguments = ExtensionSystem::PluginManager::arguments(); - if (m_sessionToRestoreAtStartup.isNull()) { + if (!lastSessionArg) { QStringList sessions = SessionManager::sessions(); // We have command line arguments, try to find a session in them // Default to no session loading @@ -2233,11 +2237,10 @@ void ProjectExplorerPluginPrivate::determineSessionToRestoreAtStartup() } } // Handle settings only after command line arguments: - if (m_sessionToRestoreAtStartup.isNull() - && m_projectExplorerSettings.autorestoreLastSession) - m_sessionToRestoreAtStartup = SessionManager::lastSession(); + if (m_sessionToRestoreAtStartup.isEmpty() && m_projectExplorerSettings.autorestoreLastSession) + m_sessionToRestoreAtStartup = SessionManager::startupSession(); - if (!m_sessionToRestoreAtStartup.isNull()) + if (!m_sessionToRestoreAtStartup.isEmpty()) ModeManager::activateMode(Core::Constants::MODE_EDIT); } diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index cc115322829..ddac904c2db 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -221,8 +221,11 @@ const char FILEOVERLAY_SCXML[]=":/projectexplorer/images/fileoverlay_scxml.png"; const char FILEOVERLAY_PY[]=":/projectexplorer/images/fileoverlay_py.png"; const char FILEOVERLAY_UNKNOWN[]=":/projectexplorer/images/fileoverlay_unknown.png"; +// Settings const char ADD_FILES_DIALOG_FILTER_HISTORY_KEY[] = "ProjectExplorer.AddFilesFilterKey"; const char PROJECT_ROOT_PATH_KEY[] = "ProjectExplorer.Project.RootPath"; +const char STARTUPSESSION_KEY[] = "ProjectExplorer/SessionToRestore"; +const char LASTSESSION_KEY[] = "ProjectExplorer/StartupSession"; } // namespace Constants } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 040ccc6af09..b386a459342 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -1137,7 +1137,12 @@ bool SessionManager::loadSession(const QString &session, bool initial) QString SessionManager::lastSession() { - return ICore::settings()->value(QLatin1String("ProjectExplorer/StartupSession")).toString(); + return ICore::settings()->value(Constants::LASTSESSION_KEY).toString(); +} + +QString SessionManager::startupSession() +{ + return ICore::settings()->value(Constants::STARTUPSESSION_KEY).toString(); } void SessionManager::reportProjectLoadingProgress() diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 3bd0b48c54e..290946f9d72 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -61,6 +61,7 @@ public: // higher level session management static QString activeSession(); static QString lastSession(); + static QString startupSession(); static QStringList sessions(); static QDateTime sessionDateTime(const QString &session);