Commit 56bdad14 authored by Eike Ziller's avatar Eike Ziller
Browse files

Fix crash with splitting and non-splittable editors



We may not just add an editor to a view without removing it from the
original view.

Task-number: QTCREATORBUG-9843
Change-Id: I1041ceb1f063bb627b5f0bd16bc3b2973a4dc3b6
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 885520d9
......@@ -1225,13 +1225,16 @@ void EditorManager::closeDuplicate(Core::IEditor *editor)
}
}
Core::IEditor *EditorManager::pickUnusedEditor() const
Core::IEditor *EditorManager::pickUnusedEditor(EditorView **foundView) const
{
foreach (IEditor *editor, openedEditors()) {
EditorView *view = viewForEditor(editor);
if (!view || view->currentEditor() != editor)
if (!view || view->currentEditor() != editor) {
if (foundView)
*foundView = view;
return editor;
}
}
return 0;
}
......@@ -1282,9 +1285,13 @@ Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core
view->addEditor(editor);
view->setCurrentEditor(editor);
if (!sourceView->currentEditor()) {
if (IEditor *replacement = pickUnusedEditor())
EditorView *replacementView = 0;
if (IEditor *replacement = pickUnusedEditor(&replacementView)) {
if (replacementView)
replacementView->removeEditor(replacement);
sourceView->addEditor(replacement);
}
}
return editor;
} else if (duplicateSupported) {
editor = duplicateEditor(editor);
......
......@@ -277,7 +277,7 @@ private:
void closeView(Internal::EditorView *view);
void emptyView(Internal::EditorView *view);
static void splitNewWindow(Internal::EditorView *view);
IEditor *pickUnusedEditor() const;
IEditor *pickUnusedEditor(Internal::EditorView **foundView = 0) const;
void addDocumentToRecentFiles(IDocument *document);
void updateAutoSave();
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment