forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user