Bug 143109

Summary: Selecting parent and child items in a tree at the same time can give unexpected results
Product: [Applications] dolphin Reporter: Shriramana Sharma <samjnaa>
Component: view-engine: details modeAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: dev+kde, goodaqua, kfm-devel, nate
Priority: NOR    
Version: 24.08.1   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Evaluating size issue
Evaluating size issue 2

Description Shriramana Sharma 2007-03-17 15:17:50 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Ubuntu Packages
OS:                Linux

-----
CASE:
-----

Let us consider a folder tree:

folder1
+- file1 1 MB
+- file2 1 MB
+- folder2
   +- file3 1 MB

--------------
QUERYING SIZE:
--------------
FIRST THE PROCEDURE THAT GIVES CORRECT RESULTS:

1. Now let us open folder1 in Konqueror and go to Tree View.
2. Let the subfolder folder2 be collapsed. 
3. Let us press Ctrl+A. file1, file2 and folder2 are selected.
4. Let us right-click the selected items and click on properties. 
5. The size of the files is shown as 3 MB. This is CORRECT.
6. Even if we had right-clicked on folder1 (by browsing to its parent directory) we would have got the same size.

NEXT THE MANIFESTATION OF THE BUG:

1. Now let us expand folder2 and hit Ctrl+A. This selects file1, file2, folder2 and file3. 
2. Now let us go to right-click properties.
3. We see 4 MB.
4. I presume this is because Konqueror is evaluating folder2's size and finds 1 MB, and then again file3 and finds 1 MB. Adding this to the sizes of file1 and file2 we get 4 MB.
5. If we go to folder1's parent, expand folder1 and select folder1 and its children and query their size, we would see similar meaningless results.

ADDITIONAL BUG RESULTING FROM PREVIOUS BUG:

1. Now let us collapse folder2 and press Ctrl+A.
2. Again let us go to right-click properties.
3. We still see 4 MB. This is inexplicable.

WHEN THIS CHILD-BUG GOES AWAY:

4. We move elsewhere in the same window and come back to folder1 and select file1, file2 and folder2.
5. We go to right-click properties.
6. Now we get back the 3 MB reading.
7. Perhaps the reason is that the size is cached in case repeated requests are made.

---------------------------------
ADDING AUDIO FILES TO A PLAYLIST:
---------------------------------

Now if these file1, file2 and file3 had been audio files, the following would also happen:

1. When folder2 is collapsed, if I drag file1, file2 and folder2 to Amarok, file1, file2 and file3 would be each added once to the playlist. This is CORRECT.
2. If I expand folder2 and select and drag file1, file2, folder2 and file3 to Amarok, file1 and file2 would each be added once and file3 would be added *twice*, just as in the previous case file3's size was evaluated twice - once for folder2 and once for itself.
3. If I have folder1 expanded (either to its direct children only or fully) and drag-drop it into Amarok, similar unintended results occur.

---------------
DELETING FILES: 
---------------

It also happens when I expand a tree in Konqueror, select the parents and children and hit Delete. KDE tries to delete the children after having deleted the parent and hence throws up an error saying it can't find the first child.

---------------------------------
EXTRACTING FILES FROM AN ARCHIVE:
---------------------------------

But this is not a Konqueror specific bug, since the same thing happens when I try to drag items from inside an archive opened in Ark to outside - whether the desktop or Konqueror or some other application is immaterial.

---------------------------------------------
CONCLUSION AND SUGGESTION FOR FIXING THE BUG:
---------------------------------------------

Ergo I conclude that this is a problem with the KTreeView class handling. If a parent and child item is selected, only one of the two should be processed, whichever is valid. 

1. If for every parent selected all its expanded children are selected, then it is sufficient to process the parent and one must ignore the children. For example in the above case if folder1, file1, file2 and folder2 is selected to be deleted and file3 is not expanded, then the application must stop with deleting folder1.

2. If for every parent selected all its expanded children are NOT selected, then only the children must be processed and not the parent. For example in the above case if folder1 and file1 are alone selected to be deleted, the operation must delete only file1. Or the application can throw up an error saying it is not possible to delete folder1 without deleting file2 and folder2 but they are not selected for deletion.

I hope this helps.
Comment 1 Andrew Crouthamel 2018-11-02 04:23:53 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 2 Andrew Crouthamel 2018-11-16 02:49:13 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version?

Thank you for helping us make KDE software even better for everyone!
Comment 3 Shriramana Sharma 2019-01-24 15:24:11 UTC
Hello and sorry for the delay.  I confirm the core bug on my Kubuntu Bionic system with the following versions:

Dolphin 17.12.3
KDE Frameworks 5.44.0
Qt 5.9.5 (built against 5.9.5)
The xcb windowing system

1) That is to say, in reporting file sizes if the children are selected then their sizes are added separately. 

2) However, the sizes don't seem to be cached so if I collapse folder2 and again ask for the sizes then I don't get the wrong result. 

3) I note that whether deleting from within Dolphin or extracting from within Ark, if a parent folder is selected along with some but not all of its contents, then the operation is performed on the parent along with all its children. I cannot totally fault this behaviour though a warning might be preferable as I have earlier suggested.

As such, the only outright *bug* right now is that in Dolphin the sizes of the children are counted and reported separately.
Comment 4 Frank Steinmetzger 2021-09-15 22:27:53 UTC
I just encountered this bug in Dolphin and a quick search brought me to this issue.

I viewed a directory which has one subdirectory and in there a few files. Like so:
+ subdirectory
  + file 1
  + file 2

To find out how big the files are, a customary way is to press Ctrl+A and then Alt+Enter to open the Properties window. This window shows me double the amount and size of the files, because both the files are counted by themselves and also "subdirectory" with its content.


Operating System: Arch Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.14.2-arch1-2 (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-4590 CPU @ 3.30GHz
Memory: 31.0 GiB of RAM
Graphics Processor: AMD PITCAIRN
Comment 5 reports_go_brrr 2024-09-20 19:06:59 UTC
Can reproduce bug associated with files sizes, but it only applies to "Properties" (Alt+Return) not to panel below with "Show Space Information" activated.
I feel old now.

Operating System: Arch Linux 
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.10.7-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 6 reports_go_brrr 2024-09-20 19:07:28 UTC
Created attachment 173919 [details]
Evaluating size issue
Comment 7 reports_go_brrr 2024-09-20 19:07:45 UTC
Created attachment 173920 [details]
Evaluating size issue 2