forked from qt-creator/qt-creator
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: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -1225,12 +1225,15 @@ 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,8 +1285,12 @@ 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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user