forked from qt-creator/qt-creator
QmlDesigner: Fix disconnecting the last connection
Amends b5aac705ea
Change-Id: I723b7d7847dfdb75d173a61b023e1fc30ea40eb4
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -309,16 +309,14 @@ ToolBarBackend::ToolBarBackend(QObject *parent)
|
|||||||
this,
|
this,
|
||||||
&ToolBarBackend::documentIndexChanged);
|
&ToolBarBackend::documentIndexChanged);
|
||||||
|
|
||||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this, [this]() {
|
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this, [this] {
|
||||||
static QMetaObject::Connection *lastConnection = nullptr;
|
static QMetaObject::Connection lastConnection;
|
||||||
delete lastConnection;
|
disconnect(lastConnection);
|
||||||
|
|
||||||
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||||
Core::EditorManager::currentDocument())) {
|
Core::EditorManager::currentDocument())) {
|
||||||
connect(textDocument->document(),
|
lastConnection = connect(textDocument->document(), &QTextDocument::modificationChanged,
|
||||||
&QTextDocument::modificationChanged,
|
this, &ToolBarBackend::isDocumentDirtyChanged);
|
||||||
this,
|
|
||||||
&ToolBarBackend::isDocumentDirtyChanged);
|
|
||||||
emit isDocumentDirtyChanged();
|
emit isDocumentDirtyChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user