┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2014-05-21 22:49:40 +0200
committerFrank Reininghaus <[email protected]>2014-05-21 22:49:40 +0200
commita46121dc510f987f2d164b43eaf5f84ea8c83cb8 (patch)
tree5dd88b57e12f29b1dba631bd2add37c98145d922 /src/kitemviews
parent6edcabf9a098ba9cb5099443a9cd227453a3f72b (diff)
parentf27c1242371db1e69edab78f0bbca05206f47adf (diff)
Merge remote-tracking branch 'origin/master' into frameworks
Conflicts: dolphin/src/search/filenamesearchprotocol.cpp
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 196172f1d..51bf546f9 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -488,6 +488,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);
@@ -502,7 +514,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;