From 017b9ba1acdd99b02bd8eba26d243b7b2a73a044 Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 11 Jul 2024 22:28:22 +0200 Subject: fix(Time): canceling only try to remove the source on unfulfilled Time objects --- src/time.vala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/time.vala b/src/time.vala index 05ffff9..4034c04 100644 --- a/src/time.vala +++ b/src/time.vala @@ -4,13 +4,16 @@ public class Time : Object { public signal void cancelled (); private Cancellable cancellable; private uint timeout_id; + private bool fulfilled = false; construct { cancellable = new Cancellable(); cancellable.cancelled.connect(() => { - Source.remove(timeout_id); - cancelled(); - dispose(); + if (!fulfilled) { + Source.remove(timeout_id); + cancelled(); + dispose(); + } }); } @@ -37,6 +40,7 @@ public class Time : Object { connect_closure(fn); timeout_id = Timeout.add(timeout, () => { now(); + fulfilled = true; return Source.REMOVE; }, prio); } @@ -45,6 +49,7 @@ public class Time : Object { connect_closure(fn); timeout_id = Idle.add(() => { now(); + fulfilled = true; return Source.REMOVE; }, prio); } -- cgit v1.2.3