┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemmodel.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2014-06-05 08:57:31 +0200
committerFrank Reininghaus <[email protected]>2014-06-05 08:57:31 +0200
commitc12dc996f535f787ab828560068a2c8b7f98c5cf (patch)
tree479d4363cd26849fc406641092196c4eaefc27b8 /src/kitemviews/kfileitemmodel.cpp
parent470e305be419646a3e1301cd9942be5f1ece58d9 (diff)
parentea713e7a791e4685be6d3c22756d59cef91fa77a (diff)
Merge remote-tracking branch 'origin/master' into frameworks
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 51bf546f9..33b29c9fc 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -397,7 +397,41 @@ int KFileItemModel::index(const KUrl& url) const
index = m_items.value(urlToFind, -1);
}
- Q_ASSERT(index >= 0 || m_items.count() == m_itemData.count());
+ if (index < 0) {
+ // The item could not be found, even though all items from m_itemData
+ // should be in m_items now. We print some diagnostic information which
+ // might help to find the cause of the problem, but only once. This
+ // prevents that obtaining and printing the debugging information
+ // wastes CPU cycles and floods the shell or .xsession-errors.
+ static bool printDebugInfo = true;
+
+ if (m_items.count() != m_itemData.count() && printDebugInfo) {
+ printDebugInfo = false;
+
+ kWarning() << "The model is in an inconsistent state.";
+ kWarning() << "m_items.count() ==" << m_items.count();
+ kWarning() << "m_itemData.count() ==" << m_itemData.count();
+
+ // Check if there are multiple items with the same URL.
+ QMultiHash<KUrl, int> indexesForUrl;
+ for (int i = 0; i < m_itemData.count(); ++i) {
+ indexesForUrl.insert(m_itemData.at(i)->item.url(), i);
+ }
+
+ foreach (const KUrl& url, indexesForUrl.uniqueKeys()) {
+ if (indexesForUrl.count(url) > 1) {
+ kWarning() << "Multiple items found with the URL" << url;
+ foreach (int index, indexesForUrl.values(url)) {
+ const ItemData* data = m_itemData.at(index);
+ kWarning() << "index" << index << ":" << data->item;
+ if (data->parent) {
+ kWarning() << "parent" << data->parent->item;
+ }
+ }
+ }
+ }
+ }
+ }
return index;
}