Bug 433247 - Folder expanded incorrectly when sorted by ascending size
Summary: Folder expanded incorrectly when sorted by ascending size
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: details mode (show other bugs)
Version: 20.12.2
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-19 13:24 UTC by GreggB
Modified: 2023-10-17 23:38 UTC (History)
3 users (show)

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


Attachments
Screen capture showing folder expansion (3.87 MB, video/webm)
2021-02-19 13:24 UTC, GreggB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description GreggB 2021-02-19 13:24:04 UTC
Created attachment 135903 [details]
Screen capture showing folder expansion

SUMMARY
When in Detail view sorted by ascending size: clicking on the arrow to expand a folder will sometimes show the folders files under a folder further down the list.

STEPS TO REPRODUCE
1. Set Dolphin to detail view
2. Navigate to a folder with many sub-folders
3. Sort by ascending size
4. Click on an arrow to expand a folder
5. If the folder expands normally, click again to collapse, then click the arrow on the following folder.

OBSERVED RESULT
For some folders the files will show as the contents of another folder further down the list. (please see attached screen cap)

EXPECTED RESULT
Every expanded folder should show it contents directly below it.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
This seems to happen more in folders with lots of sub-folders.
Comment 1 marek 2021-02-28 21:28:00 UTC
I can also reproduce it but I can reproduce the same behaviour both for ascending and descending ordering according to size. The number of folders/files does not need to be high. It can be reproduced with three folders with three files in each. Furthermore sometimes (when are folders ordered by size) it happens that seemingly random folders swap their places - for example:

.
├── a
├── b
├── c
├── d
└── e

after expanding of "c":

.
├── b
├── a
├── c
│   ├── c1
│   ├── c2
│   ├── c3
│   └── c4
├── d
└── e

System info:
Operating System: Manjaro Linux
KDE Plasma Version: 5.21.1
KDE Frameworks Version: 5.79.0
Qt Version: 5.15.2
Kernel Version: 5.10.18-1-MANJARO
OS Type: 64-bit
Graphics Platform: X11
Comment 2 Christian Muehlhaeuser 2021-07-10 17:01:55 UTC
Can you reproduce this on Arch as well.
Comment 3 Christian Muehlhaeuser 2021-07-10 17:02:49 UTC
(In reply to Christian Muehlhaeuser from comment #2)
> Can you reproduce this on Arch as well.

Sorry, I meant to say: "I can reproduce this on Arch as well."
Comment 4 Christian Muehlhaeuser 2021-07-10 17:43:06 UTC
Quickly fixed this and posted a PR ready for review: https://invent.kde.org/system/dolphin/-/merge_requests/232
Comment 5 Elvis Angelaccio 2021-07-13 19:51:41 UTC
Git commit baaf0c29b857997720b9cb0d584a44306963fb97 by Elvis Angelaccio, on behalf of Christian Muehlhaeuser.
Committed on 13/07/2021 at 19:48.
Pushed by elvisangelaccio into branch 'release/21.08'.

Ensure stable sort order when sorting by size

Folders with equal size caused the sort operation to become unstable,
as the result of lessThan was non-deterministic.

We need the fallback mechanisms at the bottom of the function to
resovle the situation and provide a stable sort order.

This also fixes expanding the contents of a folder into the wrong
parent.
FIXED-IN: 21.08

M  +13   -5    src/kitemviews/kfileitemmodel.cpp

https://invent.kde.org/system/dolphin/commit/baaf0c29b857997720b9cb0d584a44306963fb97