Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > ddfeee3bedf84e44f20049fdcc070a8a > files > 43

kdepimlibs4-4.14.10-2.2.mga5.src.rpm

From 354d6acbb401eeeb90558caf450c0a708fbb6295 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= <daniel.vratil@kdab.com>
Date: Thu, 29 Sep 2016 14:21:32 +0200
Subject: [PATCH 42/47] ETM: Properly handle retrieving ancestor for an unknown
 collection

When we get an ancestor collection that the ETM does not know about
(i.e. there is no corresponding Node in the tree) then just ignore it
instead of asserting.
---
 akonadi/entitytreemodel_p.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/akonadi/entitytreemodel_p.cpp b/akonadi/entitytreemodel_p.cpp
index d4802dfa7..1181e9dc9 100644
--- a/akonadi/entitytreemodel_p.cpp
+++ b/akonadi/entitytreemodel_p.cpp
@@ -706,10 +706,18 @@ void EntityTreeModelPrivate::retrieveAncestors(const Akonadi::Collection &collec
 void EntityTreeModelPrivate::ancestorsFetched(const Akonadi::Collection::List &collectionList)
 {
     foreach (const Collection &collection, collectionList) {
-        m_collections[collection.id()] = collection;
 
         const QModelIndex index = indexForCollection(collection);
-        Q_ASSERT(index.isValid());
+        if (!index.isValid()) {
+          // We retrieved an ancestor for which we do not have a corresponding
+          // node in our tree, which means we don't care about this ancestor.
+          // Also remove a possible dummy placeholder collection from the list
+          m_collections.remove(collection.id());
+          return;
+        }
+
+        // Replace the dummy placeholder with an actual collection
+        m_collections[collection.id()] = collection;
         dataChanged(index, index);
     }
 }
-- 
2.14.1