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
wilder-5.26
Jonathan Marten 4 years ago
parent 0c39b51de9
commit 012cfbbc0f
  1. 12
      klipper/tray.cpp
  2. 1
      klipper/tray.h

@ -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();

Loading…
Cancel
Save