From e10f81d2a8b0ff0fd70f97cce118db12417014d6 Mon Sep 17 00:00:00 2001 From: lenemter Date: Thu, 19 Dec 2024 13:12:41 +0300 Subject: [PATCH] Remove idle when the object is destroyed --- src/WindowActorFetcher.vala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/WindowActorFetcher.vala b/src/WindowActorFetcher.vala index b3aed9776..a645fcc6c 100644 --- a/src/WindowActorFetcher.vala +++ b/src/WindowActorFetcher.vala @@ -12,13 +12,22 @@ public class Gala.WindowActorFetcher : GLib.Object { public Meta.Window window { get; construct; } + private uint idle_id = 0; + public WindowActorFetcher (Meta.Window window) { Object (window: window); } + ~WindowActorFetcher () { + if (idle_id > 0) { + Source.remove (idle_id); + } + } + construct { - Idle.add (() => { + idle_id = Idle.add (() => { if (window == null) { + idle_id = 0; return Source.REMOVE; } @@ -26,6 +35,7 @@ public class Gala.WindowActorFetcher : GLib.Object { if (window_actor != null) { window_actor_ready (); + idle_id = 0; return Source.REMOVE; }