From 02d3e8b72a94bb24030c6552c5370de8fd4f9cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 6 Jan 2022 09:51:13 +0100 Subject: [PATCH] Remove timer resource during SignalMgt destructor --- extension.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extension.js b/extension.js index 171ebd3..8e0de0b 100644 --- a/extension.js +++ b/extension.js @@ -62,8 +62,9 @@ class SignalMgt { this.fullname = this.name + '@' + this.group; this.dbus = dbus; this.menu = menu; - this.signals = new WeakMap(); - this.widgets = new Array(); + this.signals = new WeakMap(); + this.widgets = new Array(); + this.timeouts = new Array(); this.nbClicks = 0; this.button = -1; @@ -80,6 +81,8 @@ class SignalMgt { destructor() { for(let widgetIdx in this.widgets) this.disconnectWidgetSignals(this.widgets[widgetIdx]); + for(let timeoutIdx in this.timeouts) + GLib.Source.remove(this.timeouts[timeoutIdx]); } updateSignals(item) { @@ -168,8 +171,9 @@ class SignalMgt { this.button = event.get_button(); this.nbClicks = 1; - Mainloop.timeout_add(this.dbus.ClutterSettings['double-click-time'], - this._doClickCallback.bind(this)); + let sourceId = Mainloop.timeout_add(this.dbus.ClutterSettings['double-click-time'], + this._doClickCallback.bind(this)); + this.timeouts.push(sourceId); } return Clutter.EVENT_PROPAGATE;