Commit 83fc8e1f authored by Eike Ziller's avatar Eike Ziller
Browse files

Fix crash at close after editor failed to open



When a file is part of a project, but fails to open in an editor, the
editor configuration would still keep a reference to the "created" editor
that in the end was not "opened".
Remove editors from the configured editors list when they are destroyed,
instead of when they are "closed".

Change-Id: Ib9680d56b737214c09f935f0088a77959ca7e8ba
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent 66ccbcbb
......@@ -121,8 +121,6 @@ EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate)
connect(SessionManager::instance(), SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
this, SLOT(slotAboutToRemoveProject(ProjectExplorer::Project*)));
connect(Core::EditorManager::instance(), SIGNAL(editorsClosed(QList<Core::IEditor*>)),
this, SLOT(editorsClosed(QList<Core::IEditor*>)));
}
EditorConfiguration::~EditorConfiguration()
......@@ -263,6 +261,9 @@ void EditorConfiguration::configureEditor(BaseTextEditor *textEditor) const
switchSettings(widget);
}
d->m_editors.append(textEditor);
connect(textEditor, &BaseTextEditor::destroyed, this, [this, textEditor]() {
d->m_editors.removeOne(textEditor);
});
}
void EditorConfiguration::deconfigureEditor(BaseTextEditor *textEditor) const
......@@ -396,13 +397,6 @@ void EditorConfiguration::slotAboutToRemoveProject(Project *project)
deconfigureEditor(editor);
}
void EditorConfiguration::editorsClosed(const QList<Core::IEditor*> &closedEditors)
{
Utils::erase(d->m_editors, [&closedEditors](Core::IEditor *editor) {
return closedEditors.contains(editor);
});
}
TabSettings actualTabSettings(const QString &fileName,
const TextDocument *baseTextdocument)
{
......
......@@ -111,7 +111,6 @@ private slots:
void setTextCodec(QTextCodec *textCodec);
void slotAboutToRemoveProject(ProjectExplorer::Project *project);
void editorsClosed(const QList<Core::IEditor*> &closedEditors);
private:
void switchSettings(TextEditor::TextEditorWidget *baseTextEditor) const;
......
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