From 560d107bafd222e3b0e0754943df5feb3577cde8 Mon Sep 17 00:00:00 2001 From: Moeta Yuko Date: Thu, 1 Aug 2024 11:45:56 +0800 Subject: [PATCH] ags: remove timeout source after notification dismissed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following log spam: (com.github.Aylur.ags:2273075): Gjs-CRITICAL **: 11:15:29.279: Object .Ags_Label (0x5f2be6736120), has been already disposed — impossible to get any property from it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs. == Stack trace for context 0x5f2be48b33d0 == #0 7ffcd01459e0 b resource:///com/github/Aylur/ags/widgets/label.js:39 (1dcdaf08bb00 @ 10) #1 5f2be497b5e0 i file:///home/foobar/.config/ags/modules/.commonwidgets/notification.js:253 (1dcdaf0b72e0 @ 10) #2 5f2be497b560 i resource:///com/github/Aylur/ags/utils/timeout.js:14 (1f5daab1150 @ 6) #3 5f2be497b498 i resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266 (1f5daa7d560 @ 139) (com.github.Aylur.ags:2273075): Gjs-CRITICAL **: 11:15:29.279: Object .Ags_Label (0x5f2be6736120), has been already disposed — impossible to set any property on it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs. == Stack trace for context 0x5f2be48b33d0 == #0 7ffcd01459e0 b resource:///com/github/Aylur/ags/widgets/label.js:51 (1dcdaf08bb00 @ 190) #1 5f2be497b5e0 i file:///home/foobar/.config/ags/modules/.commonwidgets/notification.js:253 (1dcdaf0b72e0 @ 10) #2 5f2be497b560 i resource:///com/github/Aylur/ags/utils/timeout.js:14 (1f5daab1150 @ 6) #3 5f2be497b498 i resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266 (1f5daa7d560 @ 139) --- .config/ags/modules/.commonwidgets/notification.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/.commonwidgets/notification.js b/.config/ags/modules/.commonwidgets/notification.js index 121df0b0..57840ff7 100644 --- a/.config/ags/modules/.commonwidgets/notification.js +++ b/.config/ags/modules/.commonwidgets/notification.js @@ -250,8 +250,12 @@ export default ({ className: 'txt-smaller txt-semibold', label: initTimeString, setup: initTimeString == 'Now' ? (self) => { - Utils.timeout(60000, () => self.label = getFriendlyNotifTimeString(notifObject.time)) - } : () => {}, + let id = Utils.timeout(60000, () => { + self.label = getFriendlyNotifTimeString(notifObject.time); + id = null; + }); + self.connect('destroy', () => { if (id) GLib.source_remove(id) }); + } : () => { }, }); const notifText = Box({ valign: Gtk.Align.CENTER,