From 9d6f5fc738b5447ccd2a45d01240aef78a4b9b33 Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Tue, 7 Sep 2010 18:33:56 +0200 Subject: [PATCH] Implement a -lastsession switch which restores the last session --- src/plugins/projectexplorer/ProjectExplorer.pluginspec | 1 + src/plugins/projectexplorer/projectexplorer.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/ProjectExplorer.pluginspec b/src/plugins/projectexplorer/ProjectExplorer.pluginspec index 394551f1029..e7395f77f62 100644 --- a/src/plugins/projectexplorer/ProjectExplorer.pluginspec +++ b/src/plugins/projectexplorer/ProjectExplorer.pluginspec @@ -21,5 +21,6 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General </dependencyList> <argumentList> <argument name="-customwizard-verbose">Verbose loading of custom wizards</argument> + <argument name="-lastsession">Restore the last session</argument> </argumentList> </plugin> diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index bb552c765a4..ff8ac82dcea 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -260,6 +260,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er d->m_session = new SessionManager(this); + if (arguments.contains("-lastsession")) + d->m_sessionToRestoreAtStartup = d->m_session->lastSession(); + connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project *)), this, SIGNAL(fileListChanged())); connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)), @@ -1195,7 +1198,6 @@ void ProjectExplorerPlugin::determineSessionToRestoreAtStartup() // We have command line arguments, try to find a session in them QStringList arguments = ExtensionSystem::PluginManager::instance()->arguments(); // Default to no session loading - d->m_sessionToRestoreAtStartup.clear(); foreach (const QString &arg, arguments) { if (sessions.contains(arg)) { // Session argument @@ -1203,6 +1205,7 @@ void ProjectExplorerPlugin::determineSessionToRestoreAtStartup() break; } } + if (!d->m_sessionToRestoreAtStartup.isNull()) Core::ICore::instance()->modeManager()->activateMode(Core::Constants::MODE_EDIT); } -- GitLab