From 1c0c8ddef430cd8b37dc993f2196f2b0019083c4 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 4 Feb 2020 09:48:51 +0100 Subject: [PATCH] [Notifications] Fixup setSourceModel Don't bother if the model is the same Differential Revision: https://phabricator.kde.org/D27037 --- libnotificationmanager/limitedrowcountproxymodel.cpp | 8 ++++++-- .../notificationgroupcollapsingproxymodel.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) 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);