QmlDesigner: Fix lambda unique connections for CollectionSourceModel

Fixes: QDS-11572
Change-Id: I25f3cbd8b6f806c347102ddea3855c23b30bf8f9
Reviewed-by: Shrief Gabr <shrief.gabr@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Ali Kianian
2023-12-21 15:55:32 +02:00
parent 238bc38f88
commit 6e75d21f84

View File

@@ -646,20 +646,28 @@ void CollectionSourceModel::registerCollection(const QSharedPointer<CollectionLi
if (collectionList == nullptr) if (collectionList == nullptr)
return; return;
connect(collectionList, &CollectionListModel::selectedIndexChanged, this, if (!collectionList->property("_is_registered_in_sourceModel").toBool()) {
[this, collectionList](int idx) { collectionList->setProperty("_is_registered_in_sourceModel", true);
onSelectedCollectionChanged(collectionList, idx);
}, Qt::UniqueConnection);
connect(collectionList, &CollectionListModel::collectionNameChanged, this, connect(collectionList,
&CollectionListModel::selectedIndexChanged,
this,
[this, collectionList](int idx) { onSelectedCollectionChanged(collectionList, idx); });
connect(collectionList,
&CollectionListModel::collectionNameChanged,
this,
[this, collectionList](const QString &oldName, const QString &newName) { [this, collectionList](const QString &oldName, const QString &newName) {
onCollectionNameChanged(collectionList, oldName, newName); onCollectionNameChanged(collectionList, oldName, newName);
}, Qt::UniqueConnection); });
connect(collectionList, &CollectionListModel::collectionsRemoved, this, connect(collectionList,
&CollectionListModel::collectionsRemoved,
this,
[this, collectionList](const QStringList &removedCollections) { [this, collectionList](const QStringList &removedCollections) {
onCollectionsRemoved(collectionList, removedCollections); onCollectionsRemoved(collectionList, removedCollections);
}, Qt::UniqueConnection); });
}
if (collectionList->sourceNode().isValid()) if (collectionList->sourceNode().isValid())
emit collectionNamesInitialized(collection->stringList()); emit collectionNamesInitialized(collection->stringList());