diff --git a/libnotificationmanager/limitedrowcountproxymodel.cpp b/libnotificationmanager/limitedrowcountproxymodel.cpp index aa429a9e2..f26441606 100644 --- a/libnotificationmanager/limitedrowcountproxymodel.cpp +++ b/libnotificationmanager/limitedrowcountproxymodel.cpp @@ -34,8 +34,12 @@ LimitedRowCountProxyModel::~LimitedRowCountProxyModel() = default; void LimitedRowCountProxyModel::setSourceModel(QAbstractItemModel *sourceModel) { - if (this->sourceModel()) { - disconnect(this->sourceModel(), nullptr, this, nullptr); + if (sourceModel == QAbstractProxyModel::sourceModel()) { + return; + } + + if (QAbstractProxyModel::sourceModel()) { + disconnect(QAbstractProxyModel::sourceModel(), nullptr, this, nullptr); } QSortFilterProxyModel::setSourceModel(sourceModel); diff --git a/libnotificationmanager/notificationgroupcollapsingproxymodel.cpp b/libnotificationmanager/notificationgroupcollapsingproxymodel.cpp index 34a1ac87c..c92ea5fbc 100644 --- a/libnotificationmanager/notificationgroupcollapsingproxymodel.cpp +++ b/libnotificationmanager/notificationgroupcollapsingproxymodel.cpp @@ -36,8 +36,12 @@ NotificationGroupCollapsingProxyModel::~NotificationGroupCollapsingProxyModel() void NotificationGroupCollapsingProxyModel::setSourceModel(QAbstractItemModel *source) { - if (sourceModel()) { - disconnect(sourceModel(), nullptr, this, nullptr); + if (source == QAbstractProxyModel::sourceModel()) { + return; + } + + if (QAbstractProxyModel::sourceModel()) { + disconnect(QAbstractProxyModel::sourceModel(), nullptr, this, nullptr); } QSortFilterProxyModel::setSourceModel(source);