Review Request 118055: Fix two bugs which could lead to a crash after collapsing a folder whose (direct or indirect) children were not listed completely yet
Frank Reininghaus
frank78ac at googlemail.com
Tue May 13 18:14:01 BST 2014
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/118055/
-----------------------------------------------------------
(Updated May 13, 2014, 5:14 p.m.)
Status
------
This change has been marked as submitted.
Review request for Dolphin.
Bugs: 332102
http://bugs.kde.org/show_bug.cgi?id=332102
Repository: kde-baseapps
Description
-------
This patch fixes two different bugs that can happen when collapsing a folder:
(a) When a folder is collapsed, there might be (direct or indirect) children in m_pendingItemsToInsert because KDirLister might not have finished listing the folder or one of its subfolders. If they remained in m_pendingItemsToInsert, they would be inserted into the model at some later point, but with an invalid pointer to a parent which does not exist any more. This could cause a crash.
The solution is to insert all items from m_pendingItemsToInsert immediately when collapsing any folder, such that they can then be removed, like all other children of the collapsed folder.
One thing to note is that this can in principle change the index of the collapsed folder (namely, if any items from m_pendingItemsToInsert were inserted before this folder). In that case, the index must be adjusted.
This crash and also the index adjustment are covered by a new unit test.
(b) When a folder is collapsed, we tell KDirLister to stop listing it (via KDirLister::stop()). However, there might be children of the folder which are still being listed. These children are removed from the model, but without this patch, KDirLister would still list them and possibly emit items for them at some later point. These would then be inserted into the model as top-level items (because their parent could not be found any more). This inconsistent model state could cause a crash later on (e.g., when the collapsed folder was re-expanded).
This issue is not easily unit-testable. Maybe somthing to keep in mind for KF5. One could either add a method to KDirLister which returns the listed URLs (and then verify in a unit test that KFileItemModel::setExpanded(int, bool) really does tell KDirLister to stop listing any removed URLs), or maybe even better, implement some kind of "unittest:/" kioslave which can be customized to trigger any behavior that is related to a fixed bug.
Diffs
-----
dolphin/src/kitemviews/kfileitemmodel.cpp a0f9305c
dolphin/src/tests/kfileitemmodeltest.cpp 99ee336
Diff: https://git.reviewboard.kde.org/r/118055/diff/
Testing
-------
Old and new unit tests pass. No regressions found so far.
Thanks,
Frank Reininghaus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20140513/204bcd3e/attachment.htm>
More information about the kfm-devel
mailing list