SessionManager: Improve encapsulation on save

Change-Id: I3fa5edf226c8369f9f12ccf95bf2914b50f9d48b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Orgad Shaneh
2016-10-11 15:34:06 +03:00
committed by Orgad Shaneh
parent 5b47c653c1
commit 738eaf85d1
2 changed files with 9 additions and 15 deletions

View File

@@ -1518,11 +1518,7 @@ void ProjectExplorerPlugin::openNewProjectDialog()
void ProjectExplorerPluginPrivate::showSessionManager()
{
if (SessionManager::isDefaultVirgin()) {
// do not save new virgin default sessions
} else {
SessionManager::save();
}
SessionDialog sessionDialog(ICore::mainWindow());
sessionDialog.setAutoLoadSession(dd->m_projectExplorerSettings.autorestoreLastSession);
sessionDialog.exec();
@@ -1551,12 +1547,8 @@ void ProjectExplorerPluginPrivate::savePersistentSettings()
foreach (Project *pro, SessionManager::projects())
pro->saveSettings();
if (SessionManager::isDefaultVirgin()) {
// do not save new virgin default sessions
} else {
SessionManager::save();
}
}
QSettings *s = ICore::settings();
s->setValue(QLatin1String("ProjectExplorer/StartupSession"), SessionManager::activeSession());

View File

@@ -408,6 +408,10 @@ bool SessionManager::loadingSession()
bool SessionManager::save()
{
// do not save new virgin default sessions
if (isDefaultVirgin())
return true;
emit m_instance->aboutToSaveSession();
if (!d->m_writer || d->m_writer->fileName() != sessionNameToFileName(d->m_sessionName)) {
@@ -961,12 +965,10 @@ bool SessionManager::loadSession(const QString &session)
// Allow everyone to set something in the session and before saving
emit m_instance->aboutToUnloadSession(d->m_sessionName);
if (!isDefaultVirgin()) {
if (!save()) {
d->m_loadingSession = false;
return false;
}
}
// Clean up
if (!EditorManager::closeAllEditors()) {