Bug 477195

Summary: KPhotoAlbum git master crashes when an Event tag is dragged on another Event tag in the Events screen
Product: [Applications] kphotoalbum Reporter: Victor Lobo <victor.ip.lobo>
Component: BrowserAssignee: KPhotoAlbum Bugs <kpabugs>
Status: VERIFIED FIXED    
Severity: crash    
Priority: NOR    
Version: GIT master   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Victor Lobo 2023-11-18 16:28:33 UTC
SUMMARY
KPhotoAlbum git master crashes when an Event tag is dragged on another Event tag in the Events screen. Crash occurs only in the git version (not in 5.11.0)


STEPS TO REPRODUCE
1. Open KPhotoAlbum (kphotoalbum --demo)
2. Click on the Events icon in the main window
3. Click and drag one event tag over another tag (for example in the demo click and drag tag "desktop" on tag "fun")
4. Crash

OBSERVED RESULT
Crash

EXPECTED RESULT
No crash

SOFTWARE/OS VERSIONS
Linux: openSUSE Tumbleweed 20230906; Kernel Version: 6.4.12-1-default (64-bit)
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.109.0
Qt Version: 5.15.10
KPhotoAlbum development version latest git master v5.11.0-191-g83478707


ADDITIONAL INFORMATION
1. Crash is reproducible every time the steps are followed.
2. Crash occurs even in the demo database.



Backtrace:
Application: KPhotoAlbum (kphotoalbum), signal: Aborted

[KCrash Handler]
#4  0x00007f5517891e0c in __pthread_kill_implementation () from /lib64/libc.so.6
#5  0x00007f551783f0e6 in raise () from /lib64/libc.so.6
#6  0x00007f55178268d7 in abort () from /lib64/libc.so.6
#7  0x00007f55180bb4f9 in qt_message_fatal (message=<synthetic pointer>..., context=...) at global/qlogging.cpp:1914
#8  QMessageLogger::fatal (this=this@entry=0x7ffec05e7e88, msg=msg@entry=0x7f55183d2000 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:893
#9  0x00007f55180ba730 in qt_assert (assertion=<optimized out>, file=<optimized out>, line=<optimized out>) at global/qglobal.cpp:3391
#10 0x00000000005a0c1f in DB::MemberMap::removeMemberFromGroup (this=0x7f54fc0066a8, category=..., group=..., item=...) at /home/victor/kphotoalbum/DB/MemberMap.cpp:304
#11 0x00000000006395de in Browser::TreeCategoryModel::dropMimeData (this=0x7f54fc006590, data=0x2d572b0, action=Qt::MoveAction, parent=...) at /home/victor/kphotoalbum/Browser/TreeCategoryModel.cpp:211
#12 0x00007f55182a8562 in QAbstractProxyModel::dropMimeData (this=<optimized out>, data=0x2d572b0, action=Qt::MoveAction, row=<optimized out>, column=<optimized out>, parent=...) at itemmodels/qabstractproxymodel.cpp:450
#13 0x00007f5519213be3 in QAbstractItemView::dropEvent (this=0x2be3b40, event=0x7ffec05e8410) at itemviews/qabstractitemview.cpp:2138
#14 0x00007f5518fe6d68 in QWidget::event (this=this@entry=0x2be3b40, event=event@entry=0x7ffec05e8410) at kernel/qwidget.cpp:9045
#15 0x00007f5519091f7e in QFrame::event (this=0x2be3b40, e=0x7ffec05e8410) at widgets/qframe.cpp:550
#16 0x00007f55182ed2eb in QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=receiver@entry=0x2c26fe0, event=event@entry=0x7ffec05e8410) at kernel/qcoreapplication.cpp:1190
#17 0x00007f5518fa518e in QApplicationPrivate::notify_helper (this=this@entry=0x25881e0, receiver=0x2c26fe0, e=e@entry=0x7ffec05e8410) at kernel/qapplication.cpp:3634
#18 0x00007f5518facff6 in QApplication::notify (this=<optimized out>, receiver=<optimized out>, e=0x7ffec05e8410) at kernel/qapplication.cpp:3386
#19 0x00007f55182ed568 in QCoreApplication::notifyInternal2 (receiver=0x2c26fe0, event=0x7ffec05e8410) at kernel/qcoreapplication.cpp:1064
#20 0x00007f55182ed5b2 in QCoreApplication::forwardEvent (receiver=<optimized out>, event=<optimized out>, originatingEvent=<optimized out>) at kernel/qcoreapplication.cpp:1079
#21 0x00007f5519001ff0 in QWidgetWindow::handleDropEvent (this=this@entry=0x2a9f060, event=event@entry=0x7ffec05e85d0) at kernel/qwidgetwindow.cpp:986
#22 0x00007f5519002eb2 in QWidgetWindow::event (this=0x2a9f060, event=0x7ffec05e85d0) at kernel/qwidgetwindow.cpp:342
#23 0x00007f5518fa519e in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x2a9f060, e=0x7ffec05e85d0) at kernel/qapplication.cpp:3640
#24 0x00007f55182ed568 in QCoreApplication::notifyInternal2 (receiver=0x2a9f060, event=0x7ffec05e85d0) at kernel/qcoreapplication.cpp:1064
#25 0x00007f55182ed72e in QCoreApplication::sendEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1462
#26 0x00007f551877efc8 in QGuiApplicationPrivate::processDrop (w=w@entry=0x2a9f060, dropData=dropData@entry=0x2d572b0, p=..., supportedActions=..., supportedActions@entry=..., buttons=..., buttons@entry=..., modifiers=..., modifiers@entry=...) at kernel/qguiapplication.cpp:3333
#27 0x00007f551874f8bc in QWindowSystemInterface::handleDrop (window=0x2a9f060, dropData=0x2d572b0, p=..., supportedActions=supportedActions@entry=..., buttons=buttons@entry=..., modifiers=...) at kernel/qwindowsysteminterface.cpp:938
#28 0x00007f550a92c807 in QXcbDrag::handleDrop (this=this@entry=0x24e8190, event=event@entry=0x7ffec05e87d0, b=b@entry=..., mods=mods@entry=...) at qxcbdrag.cpp:1063
#29 0x00007f550a9304bd in QXcbDrag::drop (this=0x24e8190, globalPos=..., b=..., mods=...) at qxcbdrag.cpp:567
#30 0x00007f55187c2d04 in QBasicDrag::eventFilter (this=0x24e8190, o=0x2a9f060, e=0x7ffec05e8b40) at kernel/qsimpledrag.cpp:167
#31 0x00007f55182ed1ce in QCoreApplicationPrivate::sendThroughApplicationEventFilters (this=this@entry=0x25881e0, receiver=receiver@entry=0x2d638b0, event=event@entry=0x7ffec05e8b40) at kernel/qcoreapplication.cpp:1172
#32 0x00007f5518fa51d8 in QApplicationPrivate::notify_helper (this=0x25881e0, receiver=0x2d638b0, e=0x7ffec05e8b40) at kernel/qapplication.cpp:3611
#33 0x00007f55182ed568 in QCoreApplication::notifyInternal2 (receiver=0x2d638b0, event=0x7ffec05e8b40) at kernel/qcoreapplication.cpp:1064
#34 0x00007f55182ed73e in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1474
#35 0x00007f551877d0eb in QGuiApplicationPrivate::processMouseEvent (e=0x2d5ee50) at kernel/qguiapplication.cpp:2285
#36 0x00007f551875036c in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#37 0x00007f550a91b1aa in xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:105
#38 0x00007f5514eb1ef0 in ?? () from /lib64/libglib-2.0.so.0
#39 0x00007f5514eb3b18 in ?? () from /lib64/libglib-2.0.so.0
#40 0x00007f5514eb41cc in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#41 0x00007f55183464a6 in QEventDispatcherGlib::processEvents (this=0x26621f0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#42 0x00007f55182ebffb in QEventLoop::exec (this=this@entry=0x7f54fc0037a0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#43 0x00007f55187c2363 in QBasicDrag::drag (this=0x24e8190, o=<optimized out>) at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#44 0x00007f55187bf549 in QDragManager::drag (this=0x2d23ce0, o=o@entry=0x2d797b0) at kernel/qdnd.cpp:117
#45 0x00007f55187bfa14 in QDrag::exec (this=this@entry=0x2d797b0, supportedActions=..., supportedActions@entry=..., defaultDropAction=<optimized out>) at kernel/qdrag.cpp:283
#46 0x00007f55192212d3 in QAbstractItemView::startDrag (this=this@entry=0x2be3b40, supportedActions=...) at itemviews/qabstractitemview.cpp:3764
#47 0x00007f551921fae6 in QAbstractItemView::mouseMoveEvent (this=0x2be3b40, event=<optimized out>) at itemviews/qabstractitemview.cpp:1845
#48 0x00007f5518fe6d68 in QWidget::event (this=this@entry=0x2be3b40, event=event@entry=0x7ffec05e95b0) at kernel/qwidget.cpp:9045
#49 0x00007f5519091f7e in QFrame::event (this=0x2be3b40, e=0x7ffec05e95b0) at widgets/qframe.cpp:550
#50 0x00007f55182ed2eb in QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=receiver@entry=0x2c26fe0, event=event@entry=0x7ffec05e95b0) at kernel/qcoreapplication.cpp:1190
#51 0x00007f5518fa518e in QApplicationPrivate::notify_helper (this=this@entry=0x25881e0, receiver=receiver@entry=0x2c26fe0, e=e@entry=0x7ffec05e95b0) at kernel/qapplication.cpp:3634
#52 0x00007f5518fad5cf in QApplication::notify (this=<optimized out>, receiver=<optimized out>, e=0x7ffec05e95b0) at kernel/qapplication.cpp:3084
#53 0x00007f55182ed568 in QCoreApplication::notifyInternal2 (receiver=0x2c26fe0, event=0x7ffec05e95b0) at kernel/qcoreapplication.cpp:1064
#54 0x00007f55182ed73e in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1474
#55 0x00007f5518fab92e in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x2c26fe0, event=event@entry=0x7ffec05e95b0, alienWidget=<optimized out>, nativeWidget=0x27ebd10, buttonDown=buttonDown@entry=0x7f55194f2330 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2622
#56 0x00007f5518fff7fd in QWidgetWindow::handleMouseEvent (this=this@entry=0x2a9f060, event=event@entry=0x7ffec05e9860) at kernel/qwidgetwindow.cpp:684
#57 0x00007f5519002d1f in QWidgetWindow::event (this=0x2a9f060, event=0x7ffec05e9860) at kernel/qwidgetwindow.cpp:300
#58 0x00007f5518fa519e in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x2a9f060, e=0x7ffec05e9860) at kernel/qapplication.cpp:3640
#59 0x00007f55182ed568 in QCoreApplication::notifyInternal2 (receiver=0x2a9f060, event=0x7ffec05e9860) at kernel/qcoreapplication.cpp:1064
#60 0x00007f55182ed73e in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1474
#61 0x00007f551877d0eb in QGuiApplicationPrivate::processMouseEvent (e=0x2657270) at kernel/qguiapplication.cpp:2285
#62 0x00007f551875036c in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#63 0x00007f550a91b1aa in xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:105
#64 0x00007f5514eb1ef0 in ?? () from /lib64/libglib-2.0.so.0
#65 0x00007f5514eb3b18 in ?? () from /lib64/libglib-2.0.so.0
#66 0x00007f5514eb41cc in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#67 0x00007f55183464a6 in QEventDispatcherGlib::processEvents (this=0x26621f0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#68 0x00007f55182ebffb in QEventLoop::exec (this=this@entry=0x7ffec05e9b90, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#69 0x00007f55182f4490 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#70 0x0000000000472a60 in main (argc=2, argv=0x7ffec05ea298) at /home/victor/kphotoalbum/main.cpp:161
[Inferior 1 (process 12020) detached]
Comment 1 Johannes Zarl-Zierl 2023-11-18 22:46:03 UTC
Git commit d691ee89ffbb604cd8ab7bef5b8c48fff50edddd by Johannes Zarl-Zierl.
Committed on 18/11/2023 at 23:45.
Pushed by johanneszarl into branch 'master'.

Review and document DB::MemberMap.

The MemberMap code had quite a few assertions that are better handled by
ignoring invalid requests. The documentation was added and documents
these edge-cases.

One of these assertions prevented drag&drop on the browser category page
in a category that does not yet have any tag groups.

M  +5    -2    Browser/TreeCategoryModel.cpp
M  +1    -0    CHANGELOG.md
M  +82   -70   DB/MemberMap.cpp
M  +154  -3    DB/MemberMap.h
M  +1    -2    DB/documentation.h

https://invent.kde.org/graphics/kphotoalbum/-/commit/d691ee89ffbb604cd8ab7bef5b8c48fff50edddd
Comment 2 Victor Lobo 2023-12-03 22:50:13 UTC
This works correctly now. Thank you!