SessionController: fix crash when closing a session from within a KPart on macOS
Something I noticed while trying out the Konsole KPart from within Kate on macOS... seems like the popup menu will be cleaned up (too early, or even unexpectedly?) by the QScopedPointer.
the relevant part of the backtrace I got:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000004cfda035560
Exception Codes: 0x0000000000000001, 0x000004cfda035560
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [67345]
VM Region Info: 0x4cfda035560 is not in any region. Bytes after previous region: 4809726055777 Bytes before following region: 100262353873568
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
commpage (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated)
---> GAP OF 0x5f9000000000 BYTES
MALLOC_NANO 600000000000-600008000000 [128.0M] rw-/rwx SM=PRV
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libkonsoleprivate.22.03.70.dylib 0x11f043378 QScopedPointerDeleter<KFileItemActions>::cleanup(KFileItemActions*) + 36 (qscopedpointer.h:60)
1 libkonsoleprivate.22.03.70.dylib 0x11f043344 QScopedPointer<KFileItemActions, QScopedPointerDeleter<KFileItemActions> >::~QScopedPointer() + 40 (qscopedpointer.h:107)
2 libkonsoleprivate.22.03.70.dylib 0x11f043344 QScopedPointer<KFileItemActions, QScopedPointerDeleter<KFileItemActions> >::~QScopedPointer() + 40 (qscopedpointer.h:107)
3 libkonsoleprivate.22.03.70.dylib 0x11f0399c4 QScopedPointer<KFileItemActions, QScopedPointerDeleter<KFileItemActions> >::~QScopedPointer() + 28 (qscopedpointer.h:105)
4 libkonsoleprivate.22.03.70.dylib 0x11f02cbb8 Konsole::SessionController::showDisplayContextMenu(QPoint const&) + 2404 (SessionController.cpp:1933)
5 libkonsoleprivate.22.03.70.dylib 0x11f03cef8 QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<QPoint const&>, void, void (Konsole::SessionController::*)(QPoint const&)>::call(void (Konsole::SessionController::*)(QPoint const&), Konsole::SessionController*, void**) + 128 (qobjectdefs_impl.h:152)
6 libkonsoleprivate.22.03.70.dylib 0x11f03ce40 void QtPrivate::FunctionPointer<void (Konsole::SessionController::*)(QPoint const&)>::call<QtPrivate::List<QPoint const&>, void>(void (Konsole::SessionController::*)(QPoint const&), Konsole::SessionController*, void**) + 80 (qobjectdefs_impl.h:185)
7 libkonsoleprivate.22.03.70.dylib 0x11f03cd4c QtPrivate::QSlotObject<void (Konsole::SessionController::*)(QPoint const&), QtPrivate::List<QPoint const&>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) + 148 (qobjectdefs_impl.h:418)
8 QtCore 0x108a19bc8 0x108814000 + 2120648
9 libkonsoleprivate.22.03.70.dylib 0x11f07ebd0 Konsole::TerminalDisplay::configureRequest(QPoint const&) + 96 (moc_TerminalDisplay.cpp:492)
10 libkonsoleprivate.22.03.70.dylib 0x11f145d50 Konsole::TerminalDisplay::mousePressEvent(QMouseEvent*) + 2184 (TerminalDisplay.cpp:1243)
11 QtWidgets 0x1072003e0 QWidget::event(QEvent*) + 128
12 libkonsoleprivate.22.03.70.dylib 0x11f14c578 Konsole::TerminalDisplay::event(QEvent*) + 272 (TerminalDisplay.cpp:2690)
13 QtWidgets 0x1071ca71c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 292
14 QtWidgets 0x1071cd048 QApplication::notify(QObject*, QEvent*) + 6072
15 QtCore 0x1089e9924 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 208
16 QtWidgets 0x1071cb080 QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) + 968
17 QtWidgets 0x10721dc1c 0x1071b8000 + 416796
18 QtWidgets 0x10721cc4c 0x1071b8000 + 412748
19 QtWidgets 0x1071ca71c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 292
20 QtWidgets 0x1071cbab4 QApplication::notify(QObject*, QEvent*) + 548
21 QtCore 0x1089e9924 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 208
22 QtGui 0x107cfa800 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2836
23 QtGui 0x107ce01c8 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 248
24 libqcocoa.dylib 0x10829ae98 0x108264000 + 224920
25 CoreFoundation 0x1b155cc5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
26 CoreFoundation 0x1b155cba8 __CFRunLoopDoSource0 + 208
27 CoreFoundation 0x1b155c894 __CFRunLoopDoSources0 + 268
28 CoreFoundation 0x1b155b208 __CFRunLoopRun + 820
29 CoreFoundation 0x1b155a734 CFRunLoopRunSpecific + 600
30 HIToolbox 0x1ba0f2f68 RunCurrentEventLoopInMode + 292
31 HIToolbox 0x1ba0f2bf4 ReceiveNextEventCommon + 320
32 HIToolbox 0x1ba0f2a9c _BlockUntilNextEventMatchingListInModeWithFilter + 72
33 AppKit 0x1b40b1000 _DPSNextEvent + 844
34 AppKit 0x1b40af8a4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1332
35 AppKit 0x1b40a19b4 -[NSApplication run] + 596
36 libqcocoa.dylib 0x108299cac 0x108264000 + 220332
37 QtCore 0x1089e5a08 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 524
38 QtCore 0x1089e9f50 QCoreApplication::exec() + 132
39 kate 0x102afc298 main + 10452 (main.cpp:714)
40 dyld 0x102fdd0f4 start + 520