forked from qt-creator/qt-creator
QmlDesigner: Fix deletion of connections
Since we have multiple instances of this class we cannot use a static variable. We have to use a member instead. Pick-to: qds/4.7 Task-number: QDS-14451 Change-Id: Ia85c145fb0b8a491132ca270cb62fb75809a03a0 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -393,13 +393,16 @@ ToolBarBackend::ToolBarBackend(QObject *parent)
|
||||
&ToolBarBackend::documentIndexChanged);
|
||||
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this, [this] {
|
||||
static QMetaObject::Connection lastConnection;
|
||||
disconnect(lastConnection);
|
||||
disconnect(m_documentConnection);
|
||||
|
||||
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
Core::EditorManager::currentDocument())) {
|
||||
lastConnection = connect(textDocument->document(), &QTextDocument::modificationChanged,
|
||||
this, &ToolBarBackend::isDocumentDirtyChanged);
|
||||
m_documentConnection = connect(textDocument->document(),
|
||||
&QTextDocument::modificationChanged,
|
||||
this,
|
||||
|
||||
&ToolBarBackend::isDocumentDirtyChanged);
|
||||
|
||||
emit isDocumentDirtyChanged();
|
||||
}
|
||||
});
|
||||
|
@@ -235,6 +235,7 @@ private:
|
||||
|
||||
QStringList m_openDocuments;
|
||||
QMetaObject::Connection m_kitConnection;
|
||||
QMetaObject::Connection m_documentConnection;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
Reference in New Issue
Block a user