diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 79ba761d1cb2c9846bc55e07c2e6689ebc2c53a9..c4a11d07e75ec4b368e050967ac5e633267b2b5e 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -112,7 +112,7 @@ private: } // namespace ProjectExplorer using namespace ProjectExplorer; -using Internal::SessionFile; +using namespace ProjectExplorer::Internal; void SessionFile::sessionLoadingProgress() @@ -215,7 +215,6 @@ bool SessionFile::load(const QString &fileName) qWarning() << "Could not find startup project" << startupProjectPath; } - const QVariant &editorsettings = reader.restoreValue(QLatin1String("EditorSettings")); if (editorsettings.isValid()) { connect(m_core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)), @@ -272,6 +271,7 @@ bool SessionFile::save(const QString &fileName) } writer.saveValue(QLatin1String("ProjectDependencies"), QVariant(depMap)); + writer.saveValue(QLatin1String("OpenEditors"), m_core->editorManager()->openedEditors().count()); writer.saveValue(QLatin1String("EditorSettings"), @@ -694,28 +694,16 @@ bool SessionManager::clear() if (debug) qDebug() << "SessionManager - clearing session ..."; - bool cancelled; - QList<Project *> notClosed = requestCloseOfAllFiles(&cancelled); - - bool success = !cancelled; + bool success = m_core->editorManager()->closeAllEditors(); if (success) { if (debug) qDebug() << "SessionManager - Removing projects ..."; - QList<Project *> toClose; - foreach (Project *pro, projects()) { - if (!notClosed.contains(pro)) - toClose << pro; - } - setStartupProject(0); - removeProjects(toClose); + removeProjects(projects()); } - if (!notClosed.isEmpty()) - success = false; - if (debug) qDebug() << "SessionManager - clearing session result is " << success; @@ -883,29 +871,6 @@ void SessionManager::setEditorCodec(Core::IEditor *editor, const QString &fileNa textEditor->setTextCodec(project->editorConfiguration()->defaultTextCodec()); } -QList<Project *> SessionManager::requestCloseOfAllFiles(bool *cancelled) -{ - *cancelled = false; - QList<Core::IFile*> filesToClose; - foreach (Project *pro, projects()) - filesToClose << pro->file(); - foreach (Core::IEditor *editor, m_core->editorManager()->openedEditors()) - filesToClose << editor->file(); - QList<Core::IFile*> notClosed; - if (!filesToClose.isEmpty()) - notClosed = m_core->fileManager()->saveModifiedFiles(filesToClose, cancelled); - // close editors here by hand - if (!*cancelled) { - QList<Core::IEditor*> editorsToClose; - foreach (Core::IEditor *editor, m_core->editorManager()->openedEditors()) - if (!notClosed.contains(editor->file())) - editorsToClose << editor; - m_core->editorManager()->closeEditors(editorsToClose, false); - // project files are closed/removed later (in this::clear) - } - return Core::Utils::qwConvertList<Project*>(notClosed); -} - Core::IFile *SessionManager::file() const { return m_file; diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index b2131595219b9f2d4064f04f702b339936d648cd..c0099b591f9f31d6be1a6385208b10627dbb0fd0 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -180,8 +180,6 @@ private: QStringList dependenciesOrder() const; Project *defaultStartupProject() const; - QList<Project *> requestCloseOfAllFiles(bool *cancelled); - void updateName(const QString &session); Core::ICore *m_core;