From 624d9e2c4cd9c0d5d29a0e76e91a9e587b051010 Mon Sep 17 00:00:00 2001
From: Eike Ziller <eike.ziller@digia.com>
Date: Fri, 12 Jul 2013 15:36:29 +0200
Subject: [PATCH] Move IEditor::isTemporary to IDocument

It's a property of the document implementation, not of the specific
editor instance working on it.

Change-Id: I5c3dd054e21b646e2d94b891916a096d045923f8
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
---
 src/plugins/android/androidmanifesteditor.cpp |  5 ---
 src/plugins/android/androidmanifesteditor.h   |  1 -
 src/plugins/bineditor/bineditor.cpp           |  5 ---
 src/plugins/bineditor/bineditor.h             |  2 --
 src/plugins/bineditor/bineditorplugin.cpp     |  7 ++--
 src/plugins/cmakeprojectmanager/cmakeeditor.h |  1 -
 src/plugins/coreplugin/documentmanager.cpp    |  2 +-
 .../editormanager/documentmodel.cpp           |  8 +++++
 .../coreplugin/editormanager/documentmodel.h  |  1 +
 .../editormanager/editormanager.cpp           | 35 ++++++-------------
 .../coreplugin/editormanager/editorview.cpp   |  4 +--
 .../coreplugin/editormanager/ieditor.h        |  2 --
 src/plugins/coreplugin/idocument.cpp          | 25 ++++++++++++-
 src/plugins/coreplugin/idocument.h            |  3 ++
 src/plugins/cppeditor/cppeditor.h             |  1 -
 .../debugger/debuggerinternalconstants.h      |  1 -
 src/plugins/debugger/memoryagent.cpp          |  2 +-
 src/plugins/designer/formwindoweditor.cpp     |  5 ---
 src/plugins/designer/formwindoweditor.h       |  2 --
 src/plugins/diffeditor/diffeditor.h           |  1 -
 src/plugins/diffeditor/diffeditorfile.cpp     |  1 +
 src/plugins/diffeditor/diffeditorwidget.cpp   |  1 -
 src/plugins/diffeditor/diffshoweditor.cpp     |  1 -
 .../genericprojectfileseditor.h               |  1 -
 src/plugins/glsleditor/glsleditoreditable.h   |  1 -
 src/plugins/imageviewer/imageviewer.cpp       |  5 ---
 src/plugins/imageviewer/imageviewer.h         |  1 -
 src/plugins/pythoneditor/pythoneditor.h       |  1 -
 src/plugins/qmljseditor/qmljseditoreditable.h |  1 -
 src/plugins/qnx/bardescriptoreditor.cpp       |  5 ---
 src/plugins/qnx/bardescriptoreditor.h         |  1 -
 src/plugins/qt4projectmanager/profileeditor.h |  1 -
 src/plugins/resourceeditor/resourceeditorw.h  |  1 -
 src/plugins/texteditor/plaintexteditor.h      |  1 -
 .../texteditor/snippets/snippeteditor.h       |  1 -
 src/plugins/vcsbase/submiteditorfile.cpp      |  1 +
 src/plugins/vcsbase/vcsbaseeditor.cpp         |  9 ++---
 src/plugins/vcsbase/vcsbasesubmiteditor.h     |  1 -
 38 files changed, 58 insertions(+), 89 deletions(-)

diff --git a/src/plugins/android/androidmanifesteditor.cpp b/src/plugins/android/androidmanifesteditor.cpp
index 4b5b340bb19..5f1bc1e8a39 100644
--- a/src/plugins/android/androidmanifesteditor.cpp
+++ b/src/plugins/android/androidmanifesteditor.cpp
@@ -73,11 +73,6 @@ Core::Id AndroidManifestEditor::id() const
     return Constants::ANDROID_MANIFEST_EDITOR_ID;
 }
 
-bool AndroidManifestEditor::isTemporary() const
-{
-    return false;
-}
-
 void AndroidManifestEditor::changeEditorPage(QAction *action)
 {
     AndroidManifestEditorWidget *editorWidget = static_cast<AndroidManifestEditorWidget *>(widget());
diff --git a/src/plugins/android/androidmanifesteditor.h b/src/plugins/android/androidmanifesteditor.h
index b6073d9005b..a51acefe1be 100644
--- a/src/plugins/android/androidmanifesteditor.h
+++ b/src/plugins/android/androidmanifesteditor.h
@@ -51,7 +51,6 @@ public:
     explicit AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget);
 
     Core::Id id() const;
-    bool isTemporary() const;
 
 private slots:
     void changeEditorPage(QAction *action);
diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp
index 25b12f0cc6e..516c9db178b 100644
--- a/src/plugins/bineditor/bineditor.cpp
+++ b/src/plugins/bineditor/bineditor.cpp
@@ -1623,11 +1623,6 @@ void BinEditorWidget::asIntegers(int offset, int count, quint64 &bigEndianValue,
     }
 }
 
-bool BinEditorWidget::isMemoryView() const
-{
-    return editor()->property("MemoryView").toBool();
-}
-
 void BinEditorWidget::setMarkup(const QList<Markup> &markup)
 {
     m_markup = markup;
diff --git a/src/plugins/bineditor/bineditor.h b/src/plugins/bineditor/bineditor.h
index 81b4b330453..d02402da612 100644
--- a/src/plugins/bineditor/bineditor.h
+++ b/src/plugins/bineditor/bineditor.h
@@ -119,8 +119,6 @@ public:
 
     QString addressString(quint64 address);
 
-    bool isMemoryView() const; // Is a debugger memory view without file?
-
     static const int SearchStride = 1024 * 1024;
 
     QList<Markup> markup() const { return m_markup; }
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 7308c99c709..251655ba7a1 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -270,11 +270,12 @@ public:
 
     QString suggestedFileName() const { return QString(); }
 
-    bool isModified() const { return m_widget->isMemoryView() ? false : m_widget->isModified(); }
+    bool isModified() const { return isTemporary()/*e.g. memory view*/ ? false
+                                                                       : m_widget->isModified(); }
 
     bool isFileReadOnly() const {
         const QString fn = filePath();
-        if (m_widget->isMemoryView() || fn.isEmpty())
+        if (fn.isEmpty())
             return false;
         const QFileInfo fi(fn);
         return !fi.isWritable();
@@ -355,8 +356,6 @@ public:
 
     QWidget *toolBar() { return m_toolBar; }
 
-    bool isTemporary() const { return m_widget->isMemoryView(); }
-
 private slots:
     void updateCursorPosition(int position) {
         m_addressEdit->setText(QString::number(m_widget->baseAddress() + position, 16));
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h
index 3a27b9b1cd0..52925164584 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.h
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h
@@ -58,7 +58,6 @@ public:
     bool duplicateSupported() const { return true; }
     Core::IEditor *duplicate(QWidget *parent);
     Core::Id id() const;
-    bool isTemporary() const { return false; }
 
 private slots:
     void markAsChanged();
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index 1c1a6a859c0..a90ab6c250c 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -1035,7 +1035,7 @@ void DocumentManager::syncWithEditor(const QList<Core::IContext *> &context)
         return;
 
     Core::IEditor *editor = Core::EditorManager::currentEditor();
-    if (!editor || editor->isTemporary())
+    if (!editor || editor->document()->isTemporary())
         return;
     foreach (IContext *c, context) {
         if (editor->widget() == c->widget()) {
diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp
index bd911f97372..f4191105fd0 100644
--- a/src/plugins/coreplugin/editormanager/documentmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp
@@ -278,6 +278,14 @@ int DocumentModel::indexOfDocument(IDocument *document) const
     return -1;
 }
 
+DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document) const
+{
+    int index = indexOfDocument(document);
+    if (index < 0)
+        return 0;
+    return d->m_documents.at(index);
+}
+
 QList<IDocument *> DocumentModel::openedDocuments() const
 {
     return d->m_editors.keys();
diff --git a/src/plugins/coreplugin/editormanager/documentmodel.h b/src/plugins/coreplugin/editormanager/documentmodel.h
index 6f6789558d7..e2e5c309c63 100644
--- a/src/plugins/coreplugin/editormanager/documentmodel.h
+++ b/src/plugins/coreplugin/editormanager/documentmodel.h
@@ -77,6 +77,7 @@ public:
     int documentCount() const;
     QList<Entry *> documents() const;
     int indexOfDocument(IDocument *document) const;
+    Entry *entryForDocument(IDocument *document) const;
     QList<IDocument *> openedDocuments() const;
 
     QList<IEditor *> editorsForDocument(IDocument *document) const;
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index b6742b39cb1..3db507faf23 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1104,7 +1104,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
     foreach (IEditor *editor, acceptedEditors) {
         emit editorAboutToClose(editor);
         if (!editor->document()->filePath().isEmpty()
-                && !editor->isTemporary()) {
+                && !editor->document()->isTemporary()) {
             QByteArray state = editor->saveState();
             if (!state.isEmpty())
                 d->m_editorStates.insert(editor->document()->filePath(), QVariant(state));
@@ -1421,7 +1421,7 @@ void EditorManager::addEditor(IEditor *editor)
     bool isNewDocument = false;
     d->m_documentModel->addEditor(editor, &isNewDocument);
     if (isNewDocument) {
-        const bool isTemporary = editor->isTemporary();
+        const bool isTemporary = editor->document()->isTemporary();
         const bool addWatcher = !isTemporary;
         DocumentManager::addDocument(editor->document(), addWatcher);
         if (!isTemporary)
@@ -1834,18 +1834,12 @@ bool EditorManager::saveDocumentAs(IDocument *documentParam)
 /* Adds the file name to the recent files if there is at least one non-temporary editor for it */
 void EditorManager::addDocumentToRecentFiles(IDocument *document)
 {
-    bool isTemporary = true;
-    Id editorId;
-    QList<IEditor *> editors = editorsForDocument(document);
-    foreach (IEditor *editor, editors) {
-        if (!editor->isTemporary()) {
-            editorId = editor->id();
-            isTemporary = false;
-            break;
-        }
-    }
-    if (!isTemporary)
-        DocumentManager::addToRecentFiles(document->filePath(), editorId);
+    if (document->isTemporary())
+        return;
+    DocumentModel::Entry *entry = d->m_documentModel->entryForDocument(document);
+    if (!entry)
+        return;
+    DocumentManager::addToRecentFiles(document->filePath(), entry->id());
 }
 
 void EditorManager::gotoNextDocHistory()
@@ -2164,7 +2158,7 @@ QByteArray EditorManager::saveState() const
     QList<IEditor *> editors = openedEditors();
     foreach (IEditor *editor, editors) {
         if (!editor->document()->filePath().isEmpty()
-                && !editor->isTemporary()) {
+                && !editor->document()->isTemporary()) {
             QByteArray state = editor->saveState();
             if (!state.isEmpty())
                 d->m_editorStates.insert(editor->document()->filePath(), QVariant(state));
@@ -2176,22 +2170,15 @@ QByteArray EditorManager::saveState() const
     QList<DocumentModel::Entry *> entries = d->m_documentModel->documents();
     int entriesCount = 0;
     foreach (DocumentModel::Entry *entry, entries) {
-        // TODO: isTemporary should move to IDocument
-        IEditor *editor = entry->document
-                ? d->m_documentModel->editorsForDocument(entry->document).first()
-                : 0;
         // The editor may be 0 if it was not loaded yet: In that case it is not temporary
-        if (!editor || !editor->isTemporary())
+        if (!entry->document || !entry->document->isTemporary())
             ++entriesCount;
     }
 
     stream << entriesCount;
 
     foreach (DocumentModel::Entry *entry, entries) {
-        IEditor *editor = entry->document
-                ? d->m_documentModel->editorsForDocument(entry->document).first()
-                : 0;
-        if (!editor || !editor->isTemporary())
+        if (!entry->document || !entry->document->isTemporary())
             stream << entry->fileName() << entry->displayName() << entry->id();
     }
 
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index 7ce07f322d5..f7d6f7c22e2 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -737,11 +737,11 @@ QByteArray SplitterOrView::saveState() const
         IEditor* e = editor();
 
         // don't save state of temporary or ad-hoc editors
-        if (e && (e->isTemporary() || e->document()->filePath().isEmpty())) {
+        if (e && (e->document()->isTemporary() || e->document()->filePath().isEmpty())) {
             // look for another editor that is more suited
             e = 0;
             foreach (IEditor *otherEditor, editors()) {
-                if (!otherEditor->isTemporary() && !otherEditor->document()->filePath().isEmpty()) {
+                if (!otherEditor->document()->isTemporary() && !otherEditor->document()->filePath().isEmpty()) {
                     e = otherEditor;
                     break;
                 }
diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h
index 529a141f27a..ca36b092ba1 100644
--- a/src/plugins/coreplugin/editormanager/ieditor.h
+++ b/src/plugins/coreplugin/editormanager/ieditor.h
@@ -62,8 +62,6 @@ public:
     virtual int currentColumn() const { return 0; }
     virtual void gotoLine(int line, int column = 0) { Q_UNUSED(line) Q_UNUSED(column) }
 
-    virtual bool isTemporary() const = 0;
-
     virtual QWidget *toolBar() = 0;
 
     virtual bool isDesignModePreferred() const { return false; }
diff --git a/src/plugins/coreplugin/idocument.cpp b/src/plugins/coreplugin/idocument.cpp
index 8bb8f26c080..9b4ce965b71 100644
--- a/src/plugins/coreplugin/idocument.cpp
+++ b/src/plugins/coreplugin/idocument.cpp
@@ -43,7 +43,11 @@
 
 namespace Core {
 
-IDocument::IDocument(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false)
+IDocument::IDocument(QObject *parent) : QObject(parent),
+    m_temporary(false),
+    m_infoBar(0),
+    m_hasWriteWarning(false),
+    m_restored(false)
 {
 }
 
@@ -78,6 +82,25 @@ bool IDocument::isFileReadOnly() const
     return !QFileInfo(filePath()).isWritable();
 }
 
+/*!
+    Returns if the document is a temporary that should for example not be considered
+    when saving/restoring the session state, recent files, etc. Defaults to false.
+    \sa setTemporary()
+*/
+bool IDocument::isTemporary() const
+{
+    return m_temporary;
+}
+
+/*!
+    Sets if the document is \a temporary.
+    \sa isTemporary()
+*/
+void IDocument::setTemporary(bool temporary)
+{
+    m_temporary = temporary;
+}
+
 bool IDocument::autoSave(QString *errorString, const QString &fileName)
 {
     if (!save(errorString, fileName, true))
diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h
index 76f095a60db..d257626a17c 100644
--- a/src/plugins/coreplugin/idocument.h
+++ b/src/plugins/coreplugin/idocument.h
@@ -88,6 +88,8 @@ public:
     void setDisplayName(const QString &name);
 
     virtual bool isFileReadOnly() const;
+    bool isTemporary() const;
+    void setTemporary(bool temporary);
 
     virtual QString defaultPath() const = 0;
     virtual QString suggestedFileName() const = 0;
@@ -122,6 +124,7 @@ signals:
 private:
     QString m_filePath;
     QString m_displayName;
+    bool m_temporary;
     QString m_autoSaveName;
     InfoBar *m_infoBar;
     bool m_hasWriteWarning;
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index 341d4fc8725..0a91678e09b 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -79,7 +79,6 @@ public:
     Core::IEditor *duplicate(QWidget *parent);
     Core::Id id() const;
 
-    bool isTemporary() const { return false; }
     bool open(QString *errorString, const QString &fileName, const QString &realFileName);
 
     const Utils::CommentDefinition *commentDefinition() const;
diff --git a/src/plugins/debugger/debuggerinternalconstants.h b/src/plugins/debugger/debuggerinternalconstants.h
index 98118808b78..b5ed7da1b75 100644
--- a/src/plugins/debugger/debuggerinternalconstants.h
+++ b/src/plugins/debugger/debuggerinternalconstants.h
@@ -46,7 +46,6 @@ namespace Internal {
 
 const char OPENED_BY_DEBUGGER[]         = "OpenedByDebugger";
 const char OPENED_WITH_DISASSEMBLY[]    = "DisassemblerView";
-const char OPENED_WITH_MEMORY[]         = "MemoryView";
 
 // Debug action
 const char DEBUG[]                      = "Debugger.Debug";
diff --git a/src/plugins/debugger/memoryagent.cpp b/src/plugins/debugger/memoryagent.cpp
index 735e9bc29f9..84f952d3ae6 100644
--- a/src/plugins/debugger/memoryagent.cpp
+++ b/src/plugins/debugger/memoryagent.cpp
@@ -182,7 +182,7 @@ bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags,
     if (!editor)
         return false;
     editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, QVariant(true));
-    editor->document()->setProperty(Constants::OPENED_WITH_MEMORY, QVariant(true));
+    editor->document()->setTemporary(true);
     QWidget *editorBinEditor = editor->widget();
     connectBinEditorWidget(editorBinEditor);
     MemoryView::setBinEditorReadOnly(editorBinEditor, readOnly);
diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp
index b7de0a3c06c..834c7a2a801 100644
--- a/src/plugins/designer/formwindoweditor.cpp
+++ b/src/plugins/designer/formwindoweditor.cpp
@@ -206,11 +206,6 @@ bool FormWindowEditor::restoreState(const QByteArray &state)
     return d->m_textEditor.restoreState(state);
 }
 
-bool FormWindowEditor::isTemporary() const
-{
-    return false;
-}
-
 QWidget *FormWindowEditor::toolBar()
 {
     return 0;
diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h
index 94eef91280d..3cba63b2c33 100644
--- a/src/plugins/designer/formwindoweditor.h
+++ b/src/plugins/designer/formwindoweditor.h
@@ -75,8 +75,6 @@ public:
     virtual QByteArray saveState() const;
     virtual bool restoreState(const QByteArray &state);
 
-    virtual bool isTemporary() const;
-
     virtual QWidget *toolBar();
 
     virtual bool isDesignModePreferred() const;
diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h
index 5a33e151fe1..c8f49444077 100644
--- a/src/plugins/diffeditor/diffeditor.h
+++ b/src/plugins/diffeditor/diffeditor.h
@@ -64,7 +64,6 @@ public:
     bool open(QString *errorString, const QString &fileName, const QString &realFileName);
     Core::IDocument *document();
     Core::Id id() const;
-    bool isTemporary() const { return true; }
     DiffEditorWidget *editorWidget() const { return m_editorWidget; }
 
     QWidget *toolBar();
diff --git a/src/plugins/diffeditor/diffeditorfile.cpp b/src/plugins/diffeditor/diffeditorfile.cpp
index deeb4cd81e5..7a52f708426 100644
--- a/src/plugins/diffeditor/diffeditorfile.cpp
+++ b/src/plugins/diffeditor/diffeditorfile.cpp
@@ -43,6 +43,7 @@ DiffEditorFile::DiffEditorFile(const QString &mimeType, QObject *parent) :
     m_modified(false)
 {
     setDisplayName(QCoreApplication::translate("DiffEditor", Constants::DIFF_EDITOR_DISPLAY_NAME));
+    setTemporary(true);
 }
 
 void DiffEditorFile::setModified(bool modified)
diff --git a/src/plugins/diffeditor/diffeditorwidget.cpp b/src/plugins/diffeditor/diffeditorwidget.cpp
index 1c80c978816..8b3b098dcbe 100644
--- a/src/plugins/diffeditor/diffeditorwidget.cpp
+++ b/src/plugins/diffeditor/diffeditorwidget.cpp
@@ -113,7 +113,6 @@ public:
     }
 
     Core::Id id() const { return "DiffViewEditor"; }
-    bool isTemporary() const { return false; }
 
 private slots:
     void slotTooltipRequested(TextEditor::ITextEditor *editor, const QPoint &globalPoint, int position);
diff --git a/src/plugins/diffeditor/diffshoweditor.cpp b/src/plugins/diffeditor/diffshoweditor.cpp
index 310acf03b7d..2198874daac 100644
--- a/src/plugins/diffeditor/diffshoweditor.cpp
+++ b/src/plugins/diffeditor/diffshoweditor.cpp
@@ -54,7 +54,6 @@ public:
     DiffShowEditorWidgetEditable(BaseTextEditorWidget *editorWidget) : BaseTextEditor(editorWidget) {}
 
     Core::Id id() const { return "DiffShowViewEditor"; }
-    bool isTemporary() const { return false; }
 };
 
 class DiffShowEditorWidget : public BaseTextEditorWidget
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
index a2fa73a4d7a..e5fedd2b16a 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
@@ -75,7 +75,6 @@ public:
     Core::Id id() const;
     bool duplicateSupported() const;
     Core::IEditor *duplicate(QWidget *parent);
-    bool isTemporary() const { return false; }
 };
 
 class ProjectFilesEditorWidget : public TextEditor::BaseTextEditorWidget
diff --git a/src/plugins/glsleditor/glsleditoreditable.h b/src/plugins/glsleditor/glsleditoreditable.h
index 3e6ce0a5292..9b8ecd64546 100644
--- a/src/plugins/glsleditor/glsleditoreditable.h
+++ b/src/plugins/glsleditor/glsleditoreditable.h
@@ -47,7 +47,6 @@ public:
     bool duplicateSupported() const { return true; }
     Core::IEditor *duplicate(QWidget *parent);
     Core::Id id() const;
-    bool isTemporary() const { return false; }
     bool open(QString *errorString, const QString &fileName, const QString &realFileName);
 };
 
diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp
index 0bc59e5b1ed..3604c1195a6 100644
--- a/src/plugins/imageviewer/imageviewer.cpp
+++ b/src/plugins/imageviewer/imageviewer.cpp
@@ -148,11 +148,6 @@ Core::Id ImageViewer::id() const
     return Core::Id(Constants::IMAGEVIEWER_ID);
 }
 
-bool ImageViewer::isTemporary() const
-{
-    return false;
-}
-
 QWidget *ImageViewer::toolBar()
 {
     return d->toolbar;
diff --git a/src/plugins/imageviewer/imageviewer.h b/src/plugins/imageviewer/imageviewer.h
index 1ae2e4c4e62..4ad5cbc8535 100644
--- a/src/plugins/imageviewer/imageviewer.h
+++ b/src/plugins/imageviewer/imageviewer.h
@@ -58,7 +58,6 @@ public:
     bool open(QString *errorString, const QString &fileName, const QString &realFileName);
     Core::IDocument *document();
     Core::Id id() const;
-    bool isTemporary() const;
     QWidget *toolBar();
 
 public slots:
diff --git a/src/plugins/pythoneditor/pythoneditor.h b/src/plugins/pythoneditor/pythoneditor.h
index 435fb08560d..f7bf8e33b4c 100644
--- a/src/plugins/pythoneditor/pythoneditor.h
+++ b/src/plugins/pythoneditor/pythoneditor.h
@@ -49,7 +49,6 @@ public:
     Core::IEditor *duplicate(QWidget *parent);
 
     Core::Id id() const;
-    bool isTemporary() const { return false; }
 
     /**
       Opens file for editing, actual work performed by base class
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.h b/src/plugins/qmljseditor/qmljseditoreditable.h
index 7490e871778..4ba470319ff 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.h
+++ b/src/plugins/qmljseditor/qmljseditoreditable.h
@@ -47,7 +47,6 @@ public:
     bool duplicateSupported() const { return true; }
     Core::IEditor *duplicate(QWidget *parent);
     Core::Id id() const;
-    bool isTemporary() const { return false; }
     bool open(QString *errorString, const QString &fileName, const QString &realFileName);
     bool isDesignModePreferred() const;
     void setTextCodec(QTextCodec *codec, TextCodecReason = TextCodecOtherReason);
diff --git a/src/plugins/qnx/bardescriptoreditor.cpp b/src/plugins/qnx/bardescriptoreditor.cpp
index 524ebd051a4..df9d195d283 100644
--- a/src/plugins/qnx/bardescriptoreditor.cpp
+++ b/src/plugins/qnx/bardescriptoreditor.cpp
@@ -104,11 +104,6 @@ Core::Id BarDescriptorEditor::id() const
     return Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID;
 }
 
-bool BarDescriptorEditor::isTemporary() const
-{
-    return false;
-}
-
 QWidget *BarDescriptorEditor::toolBar()
 {
     return m_toolBar;
diff --git a/src/plugins/qnx/bardescriptoreditor.h b/src/plugins/qnx/bardescriptoreditor.h
index 6da0419c5fe..707cf5540cf 100644
--- a/src/plugins/qnx/bardescriptoreditor.h
+++ b/src/plugins/qnx/bardescriptoreditor.h
@@ -67,7 +67,6 @@ public:
     bool open(QString *errorString, const QString &fileName, const QString &realFileName);
     Core::IDocument *document();
     Core::Id id() const;
-    bool isTemporary() const;
     QWidget *toolBar();
 
     EditorPage activePage() const;
diff --git a/src/plugins/qt4projectmanager/profileeditor.h b/src/plugins/qt4projectmanager/profileeditor.h
index d9e4b7b839c..fc0a15f564c 100644
--- a/src/plugins/qt4projectmanager/profileeditor.h
+++ b/src/plugins/qt4projectmanager/profileeditor.h
@@ -55,7 +55,6 @@ public:
     bool duplicateSupported() const { return true; }
     Core::IEditor *duplicate(QWidget *parent);
     Core::Id id() const;
-    bool isTemporary() const { return false; }
 };
 
 class ProFileEditorWidget : public TextEditor::BaseTextEditorWidget
diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h
index e76f1d938ab..5a3e2220059 100644
--- a/src/plugins/resourceeditor/resourceeditorw.h
+++ b/src/plugins/resourceeditor/resourceeditorw.h
@@ -92,7 +92,6 @@ public:
     QWidget *toolBar();
 
     void setSuggestedFileName(const QString &fileName);
-    bool isTemporary() const { return false; }
 
 private slots:
     void onUndoStackChanged(bool canUndo, bool canRedo);
diff --git a/src/plugins/texteditor/plaintexteditor.h b/src/plugins/texteditor/plaintexteditor.h
index 624708f878e..05f2be6fcb0 100644
--- a/src/plugins/texteditor/plaintexteditor.h
+++ b/src/plugins/texteditor/plaintexteditor.h
@@ -51,7 +51,6 @@ public:
 
     bool duplicateSupported() const { return true; }
     Core::IEditor *duplicate(QWidget *parent);
-    bool isTemporary() const { return false; }
     Core::Id id() const;
 };
 
diff --git a/src/plugins/texteditor/snippets/snippeteditor.h b/src/plugins/texteditor/snippets/snippeteditor.h
index 043e81ba698..6e4e49f1cea 100644
--- a/src/plugins/texteditor/snippets/snippeteditor.h
+++ b/src/plugins/texteditor/snippets/snippeteditor.h
@@ -50,7 +50,6 @@ public:
 
     bool duplicateSupported() const { return false; }
     Core::IEditor *duplicate(QWidget * /* parent */ ) { return 0; }
-    bool isTemporary() const { return false; }
     Core::Id id() const;
 };
 
diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp
index f4f43966d0e..1b45212b713 100644
--- a/src/plugins/vcsbase/submiteditorfile.cpp
+++ b/src/plugins/vcsbase/submiteditorfile.cpp
@@ -44,6 +44,7 @@ SubmitEditorFile::SubmitEditorFile(const QString &mimeType, QObject *parent) :
     m_mimeType(mimeType),
     m_modified(false)
 {
+    setTemporary(true);
 }
 
 void SubmitEditorFile::setModified(bool modified)
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 680eb485c6f..0d3f2d28290 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -151,23 +151,18 @@ public:
 
     Core::Id id() const { return m_id; }
 
-    bool isTemporary() const { return m_temporary; }
-    void setTemporary(bool t) { m_temporary = t; }
-
 signals:
     void describeRequested(const QString &source, const QString &change);
     void annotateRevisionRequested(const QString &source, const QString &change, int line);
 
 private:
     Core::Id m_id;
-    bool m_temporary;
 };
 
 VcsBaseEditor::VcsBaseEditor(VcsBaseEditorWidget *widget,
                              const VcsBaseEditorParameters *type)  :
     BaseTextEditor(widget),
-    m_id(type->id),
-    m_temporary(false)
+    m_id(type->id)
 {
     setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));
 }
@@ -725,7 +720,7 @@ void VcsBaseEditorWidget::setForceReadOnly(bool b)
     VcsBaseEditor *eda = qobject_cast<VcsBaseEditor *>(editor());
     QTC_ASSERT(eda != 0, return);
     setReadOnly(b);
-    eda->setTemporary(b);
+    eda->document()->setTemporary(b);
 }
 
 QString VcsBaseEditorWidget::source() const
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h
index 0752bc0cbcf..273586ad1c2 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.h
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h
@@ -115,7 +115,6 @@ public:
     bool open(QString *errorString, const QString &fileName, const QString &realFileName);
     Core::IDocument *document();
     Core::Id id() const;
-    bool isTemporary() const { return true; }
 
     QWidget *toolBar();
 
-- 
GitLab