Merge pull request #6 from status-im/fix/improper-model-reset-disconnection

Prevent disconnecting `modelReset` when the same `sourceModel` is set
This commit is contained in:
Michał 2024-10-16 12:33:34 +02:00 committed by GitHub
commit 0141cab5ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -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);