diff options
| author | Frank Reininghaus <[email protected]> | 2014-05-13 19:04:09 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2014-05-13 19:04:09 +0200 |
| commit | 66f1759b6f993c237b9652b9aa51ac9df52e5238 (patch) | |
| tree | 4f908fed0f2003db7b6dc7ca3920072af2b33edb /src/kitemviews/kfileitemmodel.cpp | |
| parent | 24d0ade8e3badf665ed80eaa7d57d1c3099546c9 (diff) | |
Ensure that all children of a collapsed folder are removed
Before this patch, any (direct or indirect) children that might have
been in m_pendingItemsToInsert, i.e., that were not inserted into the
model yet because KDirLister had not finished listing the directory
yet, would be added to the model later without a proper parent. This
could cause a crash later on.
CCBUG: 332102
FIXED-IN: 4.13.2
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index a0f9305cb..34a97de4c 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); |
