[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:06:40 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=8c2c749

The following commit has been merged in the master branch:
commit 8c2c7498ed9b064ab6d9da27d250ecde9ae55c97
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Tue Mar 26 15:41:24 2013 +0000

    Fix crashes when using debug versions of Qt
    
    Rewrite the logic of sourceDataChanged which was fundamentally broken
    This was potentially emitting onDataChanged on the invalid QModelIndex,
    especially now we use a flat model in the filtered view
    
    REVIEW: 109726
    BUG: 300600
---
 KTp/Models/contacts-filter-model.cpp | 56 +++++++++++++++++++-----------------
 KTp/Models/contacts-filter-model.h   |  3 +-
 KTp/Models/contacts-model.cpp        |  5 ++++
 3 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/KTp/Models/contacts-filter-model.cpp b/KTp/Models/contacts-filter-model.cpp
index d3bfb32..47db925 100644
--- a/KTp/Models/contacts-filter-model.cpp
+++ b/KTp/Models/contacts-filter-model.cpp
@@ -74,7 +74,9 @@ public:
     bool filterAcceptsGroup(const QModelIndex &index);
 
     void countContacts(const QModelIndex &sourceParent);
-    void sourceModelChanged(const QModelIndex &sourceIndex);
+
+    void sourceModelParentIndexChanged(const QModelIndex &sourceIndex);
+    void sourceModelIndexChanged(const QModelIndex &sourceIndex);
 
     QHash<QString, int> m_onlineContactsCounts;
     QHash<QString, int> m_totalContactsCounts;
@@ -396,19 +398,18 @@ void ContactsFilterModel::Private::countContacts(const QModelIndex &sourceParent
     m_totalContactsCounts.insert(key, tmpCounter);
 }
 
-void ContactsFilterModel::Private::sourceModelChanged(const QModelIndex &sourceIndex)
+void ContactsFilterModel::Private::sourceModelParentIndexChanged(const QModelIndex &sourceIndex)
 {
-    QModelIndex groupSourceIndex;
-    if (sourceIndex.data(KTp::RowTypeRole).toUInt() == KTp::ContactRowType) {
-        groupSourceIndex = sourceIndex.parent();
-    } else {
-        groupSourceIndex = sourceIndex;
+    if (sourceIndex.isValid()) {
+        countContacts(sourceIndex);
+        const QModelIndex mappedIndex = q->mapFromSource(sourceIndex);
+        Q_EMIT q->dataChanged(mappedIndex, mappedIndex);
     }
+}
 
-    countContacts(groupSourceIndex);
-
-    const QModelIndex mappedIndex = q->mapFromSource(sourceIndex);
-    Q_EMIT q->dataChanged(mappedIndex, mappedIndex);
+void ContactsFilterModel::Private::sourceModelIndexChanged(const QModelIndex &sourceIndex)
+{
+    sourceModelParentIndexChanged(sourceIndex.parent());
 }
 
 
@@ -459,29 +460,32 @@ void ContactsFilterModel::setSourceModel(QAbstractItemModel *sourceModel)
     // Disconnect the previous source model
     if (this->sourceModel()) {
         disconnect(this->sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
-                this, SLOT(sourceModelChanged(QModelIndex)));
+                this, SLOT(sourceModelIndexChanged(QModelIndex)));
         disconnect(this->sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
-                this, SLOT(sourceModelChanged(QModelIndex)));
+                this, SLOT(sourceModelParentIndexChanged(QModelIndex)));
         disconnect(this->sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
-                this, SLOT(sourceModelChanged(QModelIndex)));
+                this, SLOT(sourceModelParentIndexChanged(QModelIndex)));
         disconnect(this->sourceModel(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
-                this, SLOT(sourceModelChanged(QModelIndex)));
+                this, SLOT(sourceModelParentIndexChanged(QModelIndex)));
     }
 
     // Clear all cached values as they aren't valid anymore because the source model changed.
     d->m_onlineContactsCounts.clear();
     d->m_totalContactsCounts.clear();
-    QSortFilterProxyModel::setSourceModel(sourceModel);
-
-    // Connect the new source model
-    connect(this->sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
-            this, SLOT(sourceModelChanged(QModelIndex)));
-    connect(this->sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
-            this, SLOT(sourceModelChanged(QModelIndex)));
-    connect(this->sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
-            this, SLOT(sourceModelChanged(QModelIndex)));
-    connect(this->sourceModel(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
-            this, SLOT(sourceModelChanged(QModelIndex)));
+
+    if (sourceModel) {
+        QSortFilterProxyModel::setSourceModel(sourceModel);
+
+        // Connect the new source model
+        connect(this->sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+                this, SLOT(sourceModelIndexChanged(QModelIndex)));
+        connect(this->sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
+                this, SLOT(sourceModelParentIndexChanged(QModelIndex)));
+        connect(this->sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                this, SLOT(sourceModelParentIndexChanged(QModelIndex)));
+        connect(this->sourceModel(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+                this, SLOT(sourceModelParentIndexChanged(QModelIndex)));
+    }
 }
 
 void ContactsFilterModel::invalidateFilter()
diff --git a/KTp/Models/contacts-filter-model.h b/KTp/Models/contacts-filter-model.h
index f5b41a5..897ae47 100644
--- a/KTp/Models/contacts-filter-model.h
+++ b/KTp/Models/contacts-filter-model.h
@@ -302,7 +302,8 @@ private:
     class Private;
     Private * const d;
 
-    Q_PRIVATE_SLOT(d, void sourceModelChanged(const QModelIndex &index))
+    Q_PRIVATE_SLOT(d, void sourceModelParentIndexChanged(const QModelIndex &sourceIndex))
+    Q_PRIVATE_SLOT(d, void sourceModelIndexChanged(const QModelIndex &sourceIndex))
     Q_PRIVATE_SLOT(d, void countContacts(const QModelIndex &index))
 };
 
diff --git a/KTp/Models/contacts-model.cpp b/KTp/Models/contacts-model.cpp
index f472c9c..c2d4a42 100644
--- a/KTp/Models/contacts-model.cpp
+++ b/KTp/Models/contacts-model.cpp
@@ -142,6 +142,11 @@ void KTp::ContactsModel::updateGroupProxyModels()
 
     switch (d->groupMode) {
     case NoGrouping:
+        //This is a workaround to a Qt assert which gets confused when we switch from a source model that was
+        //part of the proxy chain, and is now used in the view directly
+        //
+        //do not disable until you have tested on Qt in debug mode
+        setSourceModel(0);
         setSourceModel(modelToGroup);
         break;
     case AccountGrouping:

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list