GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 00ea80dc authored by Yanko Kaneti's avatar Yanko Kaneti

timer: remove timeout on widget disposal

parent 14005c78
......@@ -80,6 +80,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
private GLib.Settings settings;
private double span;
private GLib.Timer timer;
private uint timeout_id;
private Utils.Bell bell;
private GLib.Notification notification;
[GtkChild]
......@@ -121,6 +122,14 @@ public class Face : Gtk.Stack, Clocks.Clock {
span = 0;
timer = new GLib.Timer ();
timeout_id = 0;
destroy.connect(() => {
if (timeout_id != 0) {
GLib.Source.remove(timeout_id);
timeout_id = 0;
}
});
bell = new Utils.Bell ("complete");
notification = new GLib.Notification (_("Time is up!"));
notification.set_body (_("Timer countdown finished"));
......@@ -254,14 +263,16 @@ public class Face : Gtk.Stack, Clocks.Clock {
state = State.RUNNING;
timer.start ();
GLib.Timeout.add(40, () => {
timeout_id = GLib.Timeout.add(40, () => {
if (state != State.RUNNING) {
timeout_id = 0;
return false;
}
var e = timer.elapsed ();
if (e >= span) {
reset ();
ring ();
timeout_id = 0;
return false;
}
update_countdown (e);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment