From 72eaca26db0c90ce448627e263db64d52c656b30 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Wed, 6 Oct 2010 18:05:07 +0200 Subject: [PATCH] Session: Do not save temporary editors Do not save temporary editors in the session. Chances are high that files opened in those editors are not around when the session is reopened. Task-number: QTCREATORBUG-2422 --- .../coreplugin/editormanager/editormanager.cpp | 15 ++++++++++++--- src/plugins/projectexplorer/session.cpp | 10 ++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index cad242bbffe..8fe8eec1725 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1685,6 +1685,7 @@ void EditorManager::showPopupOrSelectDocument() const } } +// Save state of all non-teporary editors. QByteArray EditorManager::saveState() const { QByteArray bytes; @@ -1694,7 +1695,8 @@ QByteArray EditorManager::saveState() const QList<IEditor *> editors = openedEditors(); foreach (IEditor *editor, editors) { - if (!editor->file()->fileName().isEmpty()) { + if (!editor->file()->fileName().isEmpty() + && !editor->isTemporary()) { QByteArray state = editor->saveState(); if (!state.isEmpty()) m_d->m_editorStates.insert(editor->file()->fileName(), QVariant(state)); @@ -1704,10 +1706,17 @@ QByteArray EditorManager::saveState() const stream << m_d->m_editorStates; QList<OpenEditorsModel::Entry> entries = m_d->m_editorModel->entries(); - stream << entries.count(); + int entriesCount = 0; + foreach (const OpenEditorsModel::Entry &entry, entries) { + if (!entry.editor->isTemporary()) + ++entriesCount; + } + + stream << entriesCount; foreach (const OpenEditorsModel::Entry &entry, entries) { - stream << entry.fileName() << entry.displayName() << entry.id().toUtf8(); + if (!entry.editor->isTemporary()) + stream << entry.fileName() << entry.displayName() << entry.id().toUtf8(); } stream << m_d->m_splitter->saveState(); diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index a492022092e..3c96a42c99c 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -269,8 +269,14 @@ bool SessionFile::save(const QString &fileName) writer.saveValue(QLatin1String("ProjectDependencies"), QVariant(depMap)); - writer.saveValue(QLatin1String("OpenEditors"), - m_core->editorManager()->openedEditors().count()); + int editorCount = 0; + QList<Core::IEditor *> editors = m_core->editorManager()->openedEditors(); + foreach (Core::IEditor *editor, editors) { + Q_ASSERT(editor); + if (!editor->isTemporary()) + ++editorCount; + } + writer.saveValue(QLatin1String("OpenEditors"), editorCount); writer.saveValue(QLatin1String("EditorSettings"), m_core->editorManager()->saveState().toBase64()); -- GitLab