SessionManager: Don't autosave the session while loading a session

Change-Id: I3ce769f9d9753b2771b349ad19a5b248a7f306d2
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Daniel Teske
2012-05-31 13:02:08 +02:00
parent a97d144a33
commit 69a7b5e824
3 changed files with 25 additions and 9 deletions

View File

@@ -1232,13 +1232,15 @@ void ProjectExplorerPlugin::savePersistentSettings()
if (d->m_shuttingDown)
return;
foreach (Project *pro, d->m_session->projects())
pro->saveSettings();
if (!d->m_session->loadingSession()) {
foreach (Project *pro, d->m_session->projects())
pro->saveSettings();
if (d->m_session->isDefaultVirgin()) {
// do not save new virgin default sessions
} else {
d->m_session->save();
if (d->m_session->isDefaultVirgin()) {
// do not save new virgin default sessions
} else {
d->m_session->save();
}
}
QSettings *s = Core::ICore::settings();
@@ -1492,7 +1494,6 @@ void ProjectExplorerPlugin::restoreSession()
Core::ICore::openFiles(combinedList, Core::ICore::OpenFilesFlags(Core::ICore::CanContainLineNumbers | Core::ICore::SwitchMode));
updateActions();
}
void ProjectExplorerPlugin::loadSession(const QString &session)

View File

@@ -93,6 +93,7 @@ SessionManager::SessionManager(QObject *parent)
m_sessionNode(new SessionNode(this)),
m_sessionName(QLatin1String("default")),
m_virginSession(true),
m_loadingSession(false),
m_startupProject(0)
{
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
@@ -291,6 +292,11 @@ void SessionManager::removeProject(Project *project)
removeProjects(QList<Project*>() << project);
}
bool SessionManager::loadingSession()
{
return m_loadingSession;
}
bool SessionManager::save()
{
if (debug)
@@ -810,17 +816,23 @@ bool SessionManager::loadSession(const QString &session)
}
}
m_loadingSession = true;
// Allow everyone to set something in the session and before saving
emit aboutToUnloadSession(m_sessionName);
if (!isDefaultVirgin()) {
if (!save())
if (!save()) {
m_loadingSession = false;
return false;
}
}
// Clean up
if (!ICore::editorManager()->closeAllEditors())
if (!ICore::editorManager()->closeAllEditors()) {
m_loadingSession = false;
return false;
}
setStartupProject(0);
removeProjects(projects());
@@ -872,6 +884,7 @@ bool SessionManager::loadSession(const QString &session)
// Starts a event loop, better do that at the very end
askUserAboutFailedProjects();
m_loadingSession = false;
return true;
}

View File

@@ -123,6 +123,7 @@ public:
QStringList projectsForSessionName(const QString &session) const;
void reportProjectLoadingProgress();
bool loadingSession();
signals:
void projectAdded(ProjectExplorer::Project *project);
void singleProjectAdded(ProjectExplorer::Project *project);
@@ -167,6 +168,7 @@ private:
mutable QStringList m_sessions;
mutable QHash<Project *, QStringList> m_projectFileCache;
bool m_loadingSession;
Project *m_startupProject;
QList<Project *> m_projects;