Bug 442275 - Creating a folder while filtering messes the filter results
Summary: Creating a folder while filtering messes the filter results
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: bars: filter (show other bugs)
Version: 21.08.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Eduardo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-10 18:14 UTC by Eduardo
Modified: 2021-11-28 13:24 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 22.04
Sentry Crash Report:


Attachments
Parent folder "a" is not displayed, despite being expanded and its child folders "b" and "b2" being displayed. (51.57 KB, image/png)
2021-09-10 18:14 UTC, Eduardo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eduardo 2021-09-10 18:14:56 UTC
Created attachment 141451 [details]
Parent folder "a" is not displayed, despite being expanded and its child folders "b" and "b2" being displayed.

SUMMARY
While filtering on expanded details view mode, if we create a folder that satisfies the filter as a child of an expanded folder, Dolphin will mess up the file listing, making the parent folder disappear and the childs appear in a buggy state without their parent being display (see screenshot).

This is a very specific bug, very difficult to explain and difficult to trigger in normal use, but it exists and I have successfully devised a simple recipe to reproduce it consistently. It is really difficult to explain in words, its better to just do the steps below and you will see the bug for yourself.

STEPS TO REPRODUCE
1. Create an empty folder anywhere, named "test" (or whatever name you desire). Open it on Dolphin.
2. Make sure you are on Details View mode with expandable folders.
3. Create a folder named "a" inside "test".
4. Right click "a", Create New -> Folder, and name it "b".
5. Expand folder "a", you should see the tree: "a" as parent and "b" as child.
6. Filter for the string "b". It should not change the view at all, since folder "b" passes the filter and "a" is shown because it is its parent.
7. Now, with the filter activated, right click "a" and create another folder named "b2" (a sibling of "b").
8. The bug is now triggered: after 1 second, folder "a" will disappear, and you will only see folders "b" and "b2", weirdly linked to no parent (screenshot).


OBSERVED RESULT
Folders "b" and "b2" are displayed linked to an invisible parent.


EXPECTED RESULT
Folder "a" should remain on display, with folders "b" and "b2" as its children passing the filter.


SOFTWARE/OS VERSIONS
Dolphin 21.08.1
Operating System: Arch Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Kernel Version: 5.14.2-arch1-2 (64-bit)
Graphics Platform: Wayland


ADDITIONAL INFORMATION
I discovered this bug while testing my solution for bug #411878. I thought I had introduced the bug, bug then I found out it was already there before my changes.
Comment 1 Eduardo 2021-09-24 15:08:01 UTC
I mentioned this in this MR, although it doesn't solve it:
https://invent.kde.org/system/dolphin/-/merge_requests/271

I intend to investigate this bug, assigning to myself.
Comment 2 Méven Car 2021-10-04 07:13:58 UTC
Git commit ed83f37f06bd5c4b38c100503c3ad4dec2a87912 by Méven Car, on behalf of Eduardo Cruz.
Committed on 04/10/2021 at 07:13.
Pushed by meven into branch 'master'.

Rewrite filter algorithm to properly support filtering with expanded folders under Detail View mode.
Related: bug 411878
FIXED-IN: 21.12

M  +63   -21   src/kitemviews/kfileitemmodel.cpp
M  +26   -12   src/tests/kfileitemmodeltest.cpp

https://invent.kde.org/system/dolphin/commit/ed83f37f06bd5c4b38c100503c3ad4dec2a87912
Comment 3 Bug Janitor Service 2021-10-12 04:52:09 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/283
Comment 4 Felix Ernst 2021-11-28 13:24:36 UTC
Git commit 3d49996615a094df8fc2cb613955abb740a0463a by Felix Ernst, on behalf of Eduardo Cruz.
Committed on 28/11/2021 at 13:24.
Pushed by felixernst into branch 'master'.

Properly display parent folders when filtering is active and items are added or refreshed

The methods slotRefreshItems(), slotItemsAdded() and slotItemsDeleted()
are adapted so they are now compatible with the new behavior of
filtering expanded folders achieved in
ed83f37f06bd5c4b38c100503c3ad4dec2a87912. The new behavior is that
expanded folders are hidden from view if neither the folder itself
nor any of its contents passes the filter. Previously expanded folders
would always stay visible no matter the filter.

A bug where the parent expanded folder would disappear after adding
or refreshing an item while filtering is also fixed.

Tests are added to make sure these behavior changes won't regress.
FIXED-IN: 22.04

M  +145  -17   src/kitemviews/kfileitemmodel.cpp
M  +11   -1    src/kitemviews/kfileitemmodel.h
M  +218  -2    src/tests/kfileitemmodeltest.cpp

https://invent.kde.org/system/dolphin/commit/3d49996615a094df8fc2cb613955abb740a0463a