Bug 477532

Summary: KPhotoAlbum crashes when refreshing a Category view when the Category is deleted
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-25 23:57:37 UTC
SUMMARY
KPhotoAlbum crashes when refreshing a Category view when the Category is deleted


STEPS TO REPRODUCE
1. Open KPhotoAlbum (kphotoalbum --demo)
2. From the main browser window click on the Places icon to go to the list of Places view
3. From the main menu go to Settings > Configure KPhotoAlbum... > Categories
4. (Save the DB now if needed) and Delete the Places category
5. Click OK to confirm deletion
6. Click OK to close the Settings window
7. From the Places view click on Refresh (F5)
8. Crash

Here Places is used as an example since it is already present but crash will also occur for other categories including new ones.

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 v5.11 and
KPhotoAlbum development version latest git master v5.12.0


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  0x00007f3cc7291dec in __pthread_kill_implementation () from /lib64/libc.so.6
#5  0x00007f3cc723f0c6 in raise () from /lib64/libc.so.6
#6  0x00007f3cc72268d7 in abort () from /lib64/libc.so.6
#7  0x00007f3cc7abb51f in qt_message_fatal (message=<synthetic pointer>..., context=...) at global/qlogging.cpp:1919
#8  QMessageLogger::fatal (this=this@entry=0x7ffd18f686e8, msg=msg@entry=0x7f3cc7dd2000 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:898
#9  0x00007f3cc7aba730 in qt_assert (assertion=<optimized out>, file=<optimized out>, line=<optimized out>) at global/qglobal.cpp:3392
#10 0x000000000062d7a3 in Browser::BrowserWidget::emitSignals (this=0x2b81930) at /home/victor/kphotoalbum/Browser/BrowserWidget.cpp:148
#11 0x000000000062d3a2 in Browser::BrowserWidget::go (this=0x2b81930) at /home/victor/kphotoalbum/Browser/BrowserWidget.cpp:107
#12 0x000000000054f9e3 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (Browser::BrowserWidget::*)()>::call(void (Browser::BrowserWidget::*)(), Browser::BrowserWidget*, void**) (f=(void (Browser::BrowserWidget::*)(Browser::BrowserWidget * const)) 0x62d314 <Browser::BrowserWidget::go()>, o=0x2b81930, arg=0x7ffd18f68b40) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:152
#13 0x000000000054ec40 in QtPrivate::FunctionPointer<void (Browser::BrowserWidget::*)()>::call<QtPrivate::List<>, void>(void (Browser::BrowserWidget::*)(), Browser::BrowserWidget*, void**) (f=(void (Browser::BrowserWidget::*)(Browser::BrowserWidget * const)) 0x62d314 <Browser::BrowserWidget::go()>, o=0x2b81930, arg=0x7ffd18f68b40) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:185
#14 0x000000000054dcbd in QtPrivate::QSlotObject<void (Browser::BrowserWidget::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x2b7df30, r=0x2b81930, a=0x7ffd18f68b40, ret=0x0) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:418
#15 0x00007f3cc7d25442 in QtPrivate::QSlotObjectBase::call (a=0x7ffd18f68b40, r=0x2b81930, this=0x2b7df30) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#16 doActivate<false> (sender=0x2b7dc60, signal_index=4, argv=0x7ffd18f68b40) at kernel/qobject.cpp:3925
#17 0x00007f3cc7d1e0af in QMetaObject::activate (sender=sender@entry=0x2b7dc60, m=m@entry=0x7f3cc8ebacc0 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7ffd18f68b40) at kernel/qobject.cpp:3985
#18 0x00007f3cc899e8b2 in QAction::triggered (this=this@entry=0x2b7dc60, _t1=<optimized out>) at .moc/moc_qaction.cpp:376
#19 0x00007f3cc89a142f in QAction::activate (this=0x2b7dc60, event=<optimized out>) at kernel/qaction.cpp:1161
#20 0x00007f3cc89a200d in QAction::event (e=<optimized out>, this=<optimized out>) at kernel/qaction.cpp:1086
#21 QAction::event (this=<optimized out>, e=<optimized out>) at kernel/qaction.cpp:1075
#22 0x00007f3cc89a519e in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x2b7dc60, e=0x7ffd18f68ce0) at kernel/qapplication.cpp:3640
#23 0x00007f3cc7ced198 in QCoreApplication::notifyInternal2 (receiver=0x2b7dc60, event=0x7ffd18f68ce0) at kernel/qcoreapplication.cpp:1064
#24 0x00007f3cc7ced35e in QCoreApplication::sendEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1462
#25 0x00007f3cc81ad661 in QShortcutMap::dispatchEvent (this=<optimized out>, e=<optimized out>) at kernel/qshortcutmap.cpp:675
#26 0x00007f3cc81ae27b in QShortcutMap::tryShortcut (this=this@entry=0x25361f8, e=e@entry=0x7ffd18f68da0) at kernel/qshortcutmap.cpp:343
#27 0x00007f3cc8153996 in QWindowSystemInterface::handleShortcutEvent (window=<optimized out>, timestamp=168132700, keyCode=16777268, modifiers=..., nativeScanCode=71, nativeVirtualKey=65474, nativeModifiers=16, text=..., autorepeat=false, count=1) at kernel/qwindowsysteminterface.cpp:477
#28 0x00007f3cc8178dbd in QGuiApplicationPrivate::processKeyEvent (e=0x7f3cac00b1d0) at kernel/qguiapplication.cpp:2398
#29 0x00007f3cc815038c in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#30 0x00007f3cb90f854a in xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:105
#31 0x00007f3cc4524f30 in ?? () from /lib64/libglib-2.0.so.0
#32 0x00007f3cc4526b58 in ?? () from /lib64/libglib-2.0.so.0
#33 0x00007f3cc452720c in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#34 0x00007f3cc7d460d6 in QEventDispatcherGlib::processEvents (this=0x2610f00, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#35 0x00007f3cc7cebc2b in QEventLoop::exec (this=this@entry=0x7ffd18f690e0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#36 0x00007f3cc7cf40c0 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#37 0x0000000000472a68 in main (argc=2, argv=0x7ffd18f697e8) at /home/victor/kphotoalbum/main.cpp:161
[Inferior 1 (process 9177) detached]
Comment 1 Johannes Zarl-Zierl 2023-11-28 22:26:22 UTC
Git commit 061acef783b3980d938aa6f4ba04a81f89ac20ce by Johannes Zarl-Zierl.
Committed on 28/11/2023 at 23:11.
Pushed by johanneszarl into branch 'master'.

Fix crash when deleting a category while its category page is shown.

When the category page was shown while its category page is shown, one
could crash kphotoalbum by refreshing the view.

New behavior: Return to the home page when a deleted category page is
refreshed.

Note: even nicer would be to automatically go to the home page without a
manual refresh in this case.

M  +5    -3    Browser/BrowserWidget.cpp

https://invent.kde.org/graphics/kphotoalbum/-/commit/061acef783b3980d938aa6f4ba04a81f89ac20ce
Comment 2 Victor Lobo 2023-12-04 00:53:56 UTC
Thank you! This bug is fixed. I did encounter another crash bug 478015 while testing this scenario so your note about "automatically go to the home page without a manual refresh" may be a better solution if easy.