Question about KDirLister and hiding expanded directories

Frank Reininghaus frank78ac at googlemail.com
Sat Jan 5 13:49:11 GMT 2013


Hi David,

after debugging a Dolphin crash,

https://bugs.kde.org/show_bug.cgi?id=311947

I have another question about KDirLister. The problem is the
following: assuming we have folders ~/a and ~/a/b, renaming ~/a to
~/.a (and thus hiding it) will have the following effects:

1. KDirLister's refreshItems signal reports that the name of ~/a/b
changes to ~/.a/b.
2. It then reports that ~/a has been deleted.

The problem is now that
KFileItemModel::slotItemsDeleted(KFileItemList), which tries to find
all children of removed items to remove them as well, cannot detect
that ~/.a/b is a child of the deleted ~/a. Therefore, we have an item
with a dangling 'parent' and get a crash when that is dereferenced.

KDirModel does not suffer from this problem because each
KDirModelDirNode node keeps a list of its children, so the
parent-child relationship is not affected by the ~/a/b -> ~/.a/b
change.

OTOH, KFileItemModel stores all items in a QList and determines the
children of an item by simply taking all following items with a larger
expansion level, until an item with the same (or a smaller) expansion
level as the parent is found.

So my question is: Would you agree that emitting the refreshItems
signal for a child of the directory that is being hidden is sort of
unexpected? And if yes, is there an easy way to fix this?

The alternative might be to move the entire "hidden files" filtering
to the model. Given that we already do filtering by name and mime type
inside the model, this looks more consistent anyway.

Best regards
Frank




More information about the kfm-devel mailing list