Prevent disconnecting modelReset when the same sourceModel is set

This commit is contained in:
Michał Cieślak 2024-10-16 11:48:39 +02:00
parent 984560cfb0
commit 53b4ab29df
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);