Bug 478398 - Crash if add menu item then immediately delete it then save
Summary: Crash if add menu item then immediately delete it then save
Status: RESOLVED FIXED
Alias: None
Product: kmenuedit
Classification: Applications
Component: general (show other bugs)
Version: 5.27.8
Platform: Kubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 450553 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-12-11 13:57 UTC by qazerr
Modified: 2024-02-26 14:24 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description qazerr 2023-12-11 13:57:43 UTC
SUMMARY
kmenuedit always crashes if you add new menu item, then immediately delete it, then click save.

STEPS TO REPRODUCE
1. add new menu item (i called mine "12345")
2. immediately delete it
3. click save
4. always crashes

OBSERVED RESULT
```
kf.service.services: The desktop entry file "/home/antix/.local/share/applications/12345.desktop" has Type= "Application" but no Exec line

Thread 1 "kmenuedit" received signal SIGSEGV, Segmentation fault.
KService::desktopEntryName (this=0x0) at /usr/src/kservice-5.110.0-0ubuntu1/src/services/kservice.cpp:991
Downloading source file /usr/src/kservice-5.110.0-0ubuntu1/src/services/kservice.cpp
991         return d->m_strDesktopEntryName;
(gdb) bt
#0  KService::desktopEntryName (this=0x0) at /usr/src/kservice-5.110.0-0ubuntu1/src/services/kservice.cpp:991
#1  0x0000555555574c37 in GlobalAccel::changeMenuEntryShortcut (service=..., shortcut=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qshareddata.h:161
#2  0x000055555558006e in MenuFolderInfo::save (this=0x55555590d790, menuFile=0x555555913350) at /usr/src/kmenuedit-4:5.27.8-0ubuntu1/menuinfo.cpp:176
#3  0x0000555555584b86 in TreeView::save (this=0x55555581dfa0) at /usr/src/kmenuedit-4:5.27.8-0ubuntu1/treeview.cpp:1719
#4  0x00007ffff650602d in doActivate<false> (sender=0x555555820ba0, signal_index=4, argv=0x7fffffffca60) at kernel/qobject.cpp:3937
#5  0x00007ffff64fec47 in QMetaObject::activate (sender=sender@entry=0x555555820ba0, m=m@entry=0x7ffff768eca0 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1,
argv=argv@entry=0x7fffffffca60) at kernel/qobject.cpp:3985
#6  0x00007ffff7165256 in QAction::triggered (this=this@entry=0x555555820ba0, _t1=<optimized out>) at .moc/moc_qaction.cpp:376
#7  0x00007ffff7167f57 in QAction::activate (this=0x555555820ba0, event=<optimized out>) at kernel/qaction.cpp:1161
#8  0x00007ffff7261aba in QAbstractButtonPrivate::click (this=0x5555559db310) at widgets/qabstractbutton.cpp:398
#9  0x00007ffff7261c0b in QAbstractButton::mouseReleaseEvent (this=0x5555559347b0, e=0x7fffffffcff0) at widgets/qabstractbutton.cpp:1044
#10 0x00007ffff735e98e in QToolButton::mouseReleaseEvent (this=<optimized out>, e=<optimized out>) at widgets/qtoolbutton.cpp:622
#11 0x00007ffff71aeb28 in QWidget::event (this=0x5555559347b0, event=0x7fffffffcff0) at kernel/qwidget.cpp:9045
#12 0x00007ffff716bc82 in QApplicationPrivate::notify_helper (this=this@entry=0x5555555b2cb0, receiver=receiver@entry=0x5555559347b0, e=e@entry=0x7fffffffcff0)
at kernel/qapplication.cpp:3640
#13 0x00007ffff71741bd in QApplication::notify (this=<optimized out>, receiver=<optimized out>, e=0x7fffffffcff0) at kernel/qapplication.cpp:3084
#14 0x00007ffff64cc7a8 in QCoreApplication::notifyInternal2 (receiver=0x5555559347b0, event=0x7fffffffcff0) at kernel/qcoreapplication.cpp:1064
#15 0x00007ffff64cc9a2 in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1474
#16 0x00007ffff71724b2 in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x5555559347b0, event=event@entry=0x7fffffffcff0, alienWidget=<optimized out>,
nativeWidget=0x5555556c5340, buttonDown=buttonDown@entry=0x7ffff76bd9d0 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false)
at kernel/qapplication.cpp:2622
#17 0x00007ffff71c7da1 in QWidgetWindow::handleMouseEvent (this=this@entry=0x555555912f50, event=event@entry=0x7fffffffd2a0) at kernel/qwidgetwindow.cpp:684
#18 0x00007ffff71cb12f in QWidgetWindow::event (this=0x555555912f50, event=0x7fffffffd2a0) at kernel/qwidgetwindow.cpp:300
#19 0x00007ffff716bc82 in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x555555912f50, e=0x7fffffffd2a0) at kernel/qapplication.cpp:3640
#20 0x00007ffff64cc7a8 in QCoreApplication::notifyInternal2 (receiver=0x555555912f50, event=0x7fffffffd2a0) at kernel/qcoreapplication.cpp:1064
#21 0x00007ffff64cc9a2 in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1474
#22 0x00007ffff6943bdb in QGuiApplicationPrivate::processMouseEvent (e=0x555555d9c2a0) at kernel/qguiapplication.cpp:2278
#23 0x00007ffff691762c in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#24 0x00007ffff14dcf7e in xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:105
#25 0x00007ffff4b13b2c in g_main_dispatch (context=0x7fffec000ec0) at ../../../glib/gmain.c:3476
#26 0x00007ffff4b6f46f in g_main_context_dispatch_unlocked (context=0x7fffec000ec0) at ../../../glib/gmain.c:4284
#27 g_main_context_iterate_unlocked.isra.0 (context=context@entry=0x7fffec000ec0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../glib/gmain.c:4349
#28 0x00007ffff4b11d20 in g_main_context_iteration (context=0x7fffec000ec0, may_block=1) at ../../../glib/gmain.c:4414
#29 0x00007ffff6527daa in QEventDispatcherGlib::processEvents (this=0x555555691810, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#30 0x00007ffff64cb15b in QEventLoop::exec (this=this@entry=0x7fffffffd5d0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#31 0x00007ffff64d3904 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
--Type <RET> for more, q to quit, c to continue without paging--
#32 0x00007ffff6937610 in QGuiApplication::exec () at kernel/qguiapplication.cpp:1863
#33 0x00007ffff716bbf9 in QApplication::exec () at kernel/qapplication.cpp:2832
#34 0x000055555556d941 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/kmenuedit-4:5.27.8-0ubuntu1/main.cpp:93
(gdb)
```


EXPECTED RESULT
no crash

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Kubuntu 23.10
(available in About System)
KDE Plasma Version: 5.27.8
KDE Frameworks Version:  5.110.0
Qt Version:  5.15.10

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2023-12-12 12:35:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kmenuedit/-/merge_requests/30
Comment 2 Harald Sitter 2023-12-12 13:24:23 UTC
Git commit a299ab863117ae455dc8c522b39719c69f215587 by Harald Sitter.
Committed on 12/12/2023 at 13:35.
Pushed by sitter into branch 'master'.

globalaccel: don't trip over missing services

this notably happens when creating an item and immediately deleting it
again, before saving. in that scenario the service doesn't actually
exist yet and consequently there are no global shortcuts to clean up
anyway.

M  +4    -0    globalaccel.cpp

https://invent.kde.org/plasma/kmenuedit/-/commit/a299ab863117ae455dc8c522b39719c69f215587
Comment 3 Harald Sitter 2024-02-26 14:24:29 UTC
*** Bug 450553 has been marked as a duplicate of this bug. ***