diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index f4c7f9d0a4c..1566cf85863 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1462,7 +1462,10 @@ IEditor *EditorManagerPrivate::createEditor(IEditorFactory *factory, const FileP IEditor *editor = factory->createEditor(); if (editor) { QTC_CHECK(editor->document()->id().isValid()); // sanity check that the editor has an id set - connect(editor->document(), &IDocument::changed, d, &EditorManagerPrivate::handleDocumentStateChange); + IDocument *document = editor->document(); + connect(document, &IDocument::changed, d, [document] { + d->handleDocumentStateChange(document); + }); emit m_instance->editorCreated(editor, filePath.toString()); } @@ -2311,10 +2314,9 @@ void EditorManagerPrivate::vcsOpenCurrentEditor() } } -void EditorManagerPrivate::handleDocumentStateChange() +void EditorManagerPrivate::handleDocumentStateChange(IDocument *document) { updateActions(); - auto document = qobject_cast(sender()); if (!document->isModified()) document->removeAutoSaveFile(); if (EditorManager::currentDocument() == document) diff --git a/src/plugins/coreplugin/editormanager/editormanager_p.h b/src/plugins/coreplugin/editormanager/editormanager_p.h index 571299f54b3..26a3e8a8dc8 100644 --- a/src/plugins/coreplugin/editormanager/editormanager_p.h +++ b/src/plugins/coreplugin/editormanager/editormanager_p.h @@ -163,7 +163,7 @@ public slots: static void gotoPreviousSplit(); static void gotoNextSplit(); - void handleDocumentStateChange(); + void handleDocumentStateChange(Core::IDocument *document); void editorAreaDestroyed(QObject *area); signals: