Bug 472109

Summary: "Sort selected by date" can be used to trigger a crash
Product: [Applications] kphotoalbum Reporter: Johannes Zarl-Zierl <johannes>
Component: generalAssignee: KPhotoAlbum Bugs <kphotoalbum-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Johannes Zarl-Zierl 2023-07-09 21:33:56 UTC
SUMMARY

STEPS TO REPRODUCE
1.  Start kphotoalbum --demo
2. Set up preconditions for failure:
  a. Go to thumbnail view
  b. Select two images an create a stack
  c. Press "Refresh"
  d. Now the database has a stack
3. Select all images (using Ctrl-A)
4. Click "View | Expand all stacks"
5. No images are selected
6. Click "View | Sort selected by Date & Time"


OBSERVED RESULT
KPhotoAlbum crashes

EXPECTED RESULT
Menu entry "View | Sort selected by Date & Time" should have been disabled and clicking it should not have crashed the program.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Johannes Zarl-Zierl 2023-07-09 22:08:47 UTC
Git commit 736882a98da8fefc56b7f3c4a2d2db68ce00ff67 by Johannes Zarl-Zierl.
Committed on 09/07/2023 at 22:04.
Pushed by johanneszarl into branch 'master'.

Prevent inconsistent UI when thumbnail model is reset

If an action like "Collaps all stacks" is called, the thumbnail model is
reset, thus invalidating the selection.
Unfortunately, this does not trigger a selectionChanged signal because
the selection is reset and not cleared.

This would lead to an inconsistent UI, where actions that depend on an
existing selection would not be disabled, despite there not being a
selection.

M  +13   -2    DB/ImageInfoList.cpp
M  +15   -3    ThumbnailView/ThumbnailWidget.cpp

https://invent.kde.org/graphics/kphotoalbum/-/commit/736882a98da8fefc56b7f3c4a2d2db68ce00ff67