From 53b4ab29dfa8c669c576a31ff5c1b129f6b11780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Wed, 16 Oct 2024 11:48:39 +0200 Subject: [PATCH] Prevent disconnecting modelReset when the same sourceModel is set --- qqmlsortfilterproxymodel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qqmlsortfilterproxymodel.cpp b/qqmlsortfilterproxymodel.cpp index 9bf44c3..b98e495 100644 --- a/qqmlsortfilterproxymodel.cpp +++ b/qqmlsortfilterproxymodel.cpp @@ -399,6 +399,9 @@ void QQmlSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) // SFPM creation or after source model reset it's necessary to re-initialize // role names if the source was empty before insertion. + if (this->sourceModel() == sourceModel) + return; + if (auto currentSource = this->sourceModel()) { disconnect(currentSource, &QAbstractItemModel::rowsInserted, this, &QQmlSortFilterProxyModel::initRoles);