Bug 293186

Summary: Crash when arranging thumbnails
Product: [Applications] kphotoalbum Reporter: Miika Turkia <miika.turkia>
Component: Thumbnail ViewerAssignee: KPhotoAlbum Bugs <kpabugs>
Status: RESOLVED FIXED    
Severity: crash CC: andreas.neustifter
Priority: NOR    
Version: SVN trunk (KDE4 version)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Miika Turkia 2012-02-03 05:50:34 UTC
Version:           SVN trunk (KDE4 version)
OS:                Linux

A crash occurs when selecting thumbnials with ctrl-clicking them and then dragging the selection to new location.

Reproducible: Always

Steps to Reproduce:
- view thumbnails
- select one thumbnail
- select the previous thumbnail while pressing ctrl key
- grab either of the selected images and drag it to different location
- answer yes if you are prompted whether you really want to do this

Actual Results:  
crash

Expected Results:  
All selected items to be moved to selected location without crashes (note that removing the Q_ASSERT prevents the crash but skip rearranging of some images)

This functionality expects the selection to be sorted. However, no sorting occurs when selecting individual images (the Qt documentation even states that the selection is not sorted). Thus the whole rearrangement is faulty if the selection happens to contain unordered items. And a Q_ASSERT ensures a crash.

Buggy code is in file XMLDB/Database.cpp and function
DB::ImageInfoList XMLDB::Database::takeImagesFromSelection

#10 0x00007f23dd124994 in qFatal(char const*, ...) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#11 0x000000000046c0d8 in XMLDB::Database::takeImagesFromSelection (this=0x2991d00, selection=...) at /opt/kpa/kpa-git/kphotoalbum/XMLDB/Database.cpp:398
#12 0x000000000046c212 in XMLDB::Database::reorder (this=0x2991d00, item=..., selection=..., after=true) at /opt/kpa/kpa-git/kphotoalbum/XMLDB/Database.cpp:368