diff --git a/klipper/tray.cpp b/klipper/tray.cpp index 857e3a1e2..174d0d18b 100644 --- a/klipper/tray.cpp +++ b/klipper/tray.cpp @@ -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; diff --git a/klipper/tray.h b/klipper/tray.h index bcc0777af..e17d97d4a 100644 --- a/klipper/tray.h +++ b/klipper/tray.h @@ -16,6 +16,7 @@ class KlipperTray : public KStatusNotifierItem public: KlipperTray(); + ~KlipperTray() override; public Q_SLOTS: void slotSetToolTipFromHistory();