forked from qt-creator/qt-creator
Fix semantics of "-lastsession"
Opening Qt Creator, closing it again, and then opening Qt Creator with "-lastsession" opened some session - the last session that was opened in Qt Creator at some earlier time. The intention of "-lastsession" was more to re-open Qt Creator in the state it was last closed from, so in this case it makes more sense to not open a session at all. Change-Id: Ia33ac5b79d93c7c97865186c56db2ef0b33b9f7c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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()
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user