Commit 012cfbbc authored by Jonathan Marten's avatar Jonathan Marten
Browse files

Klipper: Avoid a crash on exit with the legacy application

Caused by the context menu and the associated widget being set to the
same object, leading to an access after destruction.

 Application: Klipper (klipper), signal: Segmentation fault
 Content of s_kcrashErrorMessage: std::unique_ptr<char []> = {get() = 0x0}
 #8 QObject::disconnect (member=0x0, ...)
 #9 KStatusNotifierItem::~KStatusNotifierItem () at knotifications/src/kstatusnotifieritem.cpp:71
 #10 KlipperTray::~KlipperTray () at plasma-workspace/klipper/tray.h:13
parent 0c39b51d
Pipeline #181420 passed with stage
in 11 minutes and 30 seconds
......@@ -34,6 +34,18 @@ KlipperTray::KlipperTray()
slotSetToolTipFromHistory();
}
KlipperTray::~KlipperTray()
{
// Klipper abuses the KStatusNotifierItem slightly by setting both
// the associated widget and the context menu to the same widget,
// the KlipperPopup. This is done so that either a left click or a
// right click on the icon brings up the combined menu. Unfortunately
// this causes a crash in ~KStatusNotifierItem() when it first
// deletes the menu and then tries to disconnect the associated widget.
// Work around this by resetting the associated widget first.
setAssociatedWidget(nullptr);
}
void KlipperTray::slotSetToolTipFromHistory()
{
const int TOOLTIP_LENGTH_LIMIT = 200;
......
......@@ -16,6 +16,7 @@ class KlipperTray : public KStatusNotifierItem
public:
KlipperTray();
~KlipperTray() override;
public Q_SLOTS:
void slotSetToolTipFromHistory();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment