┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2014-05-13 19:14:25 +0200
committerFrank Reininghaus <[email protected]>2014-05-13 19:14:25 +0200
commitd152bfc53bfe6cce2a69e0ab260b0d888d7c587c (patch)
tree726e309223248a2eebd43b77f1b605cdb37c248a /src/kitemviews
parent5780fab172e02c3dd44082aa10d37cd87a98e29b (diff)
parent99e8f8e2e6b6982d1a58185d0980be203d6061ec (diff)
Merge branch 'KDE/4.13'
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index a0f9305cb..de3c3eb22 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -486,6 +486,18 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
m_urlsToExpand.insert(url);
}
} else {
+ // Note that there might be (indirect) children of the folder which is to be collapsed in
+ // m_pendingItemsToInsert. To prevent that they will be inserted into the model later,
+ // possibly without a parent, which might result in a crash, we insert all pending items
+ // right now. All new items which would be without a parent will then be removed.
+ dispatchPendingItemsToInsert();
+
+ // Check if the index of the collapsed folder has changed. If that is the case, then items
+ // were inserted before the collapsed folder, and its index needs to be updated.
+ if (m_itemData.at(index)->item != item) {
+ index = this->index(item);
+ }
+
m_expandedDirs.remove(targetUrl);
m_dirLister->stop(url);
@@ -500,7 +512,9 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
ItemData* itemData = m_itemData.at(childIndex);
if (itemData->values.value("isExpanded").toBool()) {
const KUrl targetUrl = itemData->item.targetUrl();
+ const KUrl url = itemData->item.url();
m_expandedDirs.remove(targetUrl);
+ m_dirLister->stop(url); // TODO: try to unit-test this, see https://bugs.kde.org/show_bug.cgi?id=332102#c11
expandedChildren.append(targetUrl);
}
++childIndex;