summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-07-11 22:28:22 +0200
committerAylur <[email protected]>2024-07-11 22:28:22 +0200
commit017b9ba1acdd99b02bd8eba26d243b7b2a73a044 (patch)
tree4006c67425cefac05110cefb5bb5a147e6213e57 /src
parentbd1d1f0daf989aad13823c589a9e4ce4798f5690 (diff)
fix(Time): canceling
only try to remove the source on unfulfilled Time objects
Diffstat (limited to 'src')
-rw-r--r--src/time.vala11
1 files changed, 8 insertions, 3 deletions
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);
}