forked from qt-creator/qt-creator
EditorManager: Avoid using sender()
Change-Id: I13cf8d2df014cb5f8b7979818f238f44c709333f Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -1462,7 +1462,10 @@ IEditor *EditorManagerPrivate::createEditor(IEditorFactory *factory, const FileP
|
|||||||
IEditor *editor = factory->createEditor();
|
IEditor *editor = factory->createEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
QTC_CHECK(editor->document()->id().isValid()); // sanity check that the editor has an id set
|
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());
|
emit m_instance->editorCreated(editor, filePath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2311,10 +2314,9 @@ void EditorManagerPrivate::vcsOpenCurrentEditor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManagerPrivate::handleDocumentStateChange()
|
void EditorManagerPrivate::handleDocumentStateChange(IDocument *document)
|
||||||
{
|
{
|
||||||
updateActions();
|
updateActions();
|
||||||
auto document = qobject_cast<IDocument *>(sender());
|
|
||||||
if (!document->isModified())
|
if (!document->isModified())
|
||||||
document->removeAutoSaveFile();
|
document->removeAutoSaveFile();
|
||||||
if (EditorManager::currentDocument() == document)
|
if (EditorManager::currentDocument() == document)
|
||||||
|
@@ -163,7 +163,7 @@ public slots:
|
|||||||
static void gotoPreviousSplit();
|
static void gotoPreviousSplit();
|
||||||
static void gotoNextSplit();
|
static void gotoNextSplit();
|
||||||
|
|
||||||
void handleDocumentStateChange();
|
void handleDocumentStateChange(Core::IDocument *document);
|
||||||
void editorAreaDestroyed(QObject *area);
|
void editorAreaDestroyed(QObject *area);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
Reference in New Issue
Block a user