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,
|
||||
&ToolBarBackend::documentIndexChanged);
|
||||
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this, [this]() {
|
||||
static QMetaObject::Connection *lastConnection = nullptr;
|
||||
delete lastConnection;
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this, [this] {
|
||||
static QMetaObject::Connection lastConnection;
|
||||
disconnect(lastConnection);
|
||||
|
||||
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
Core::EditorManager::currentDocument())) {
|
||||
connect(textDocument->document(),
|
||||
&QTextDocument::modificationChanged,
|
||||
this,
|
||||
&ToolBarBackend::isDocumentDirtyChanged);
|
||||
lastConnection = connect(textDocument->document(), &QTextDocument::modificationChanged,
|
||||
this, &ToolBarBackend::isDocumentDirtyChanged);
|
||||
emit isDocumentDirtyChanged();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user