[gnome-boxes] notification: Remove signal source on timeout
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] notification: Remove signal source on timeout
- Date: Tue, 25 Jul 2017 11:53:04 +0000 (UTC)
commit 08ce741a78e78ecf2fad87503ad8ebcded6fff52
Author: Thiago Mendes <tribeirom gmail com>
Date: Thu Jul 20 15:27:20 2017 -0500
notification: Remove signal source on timeout
Notifications are persisting throughout Boxes lifetime,
causing the callbacks to run indefinitely.
Deattaching the source from the mainloop context prevents
the notifications' callback from running forever.
https://bugzilla.gnome.org/show_bug.cgi?id=781468
src/notification.vala | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/src/notification.vala b/src/notification.vala
index f02bf24..32c5228 100644
--- a/src/notification.vala
+++ b/src/notification.vala
@@ -31,18 +31,19 @@ private class Boxes.Notification: Gtk.Revealer {
* lets use the respective property setter method.
*/
set_reveal_child (true);
+ uint notification_timeout_id = 0;
this.timeout = timeout;
- Timeout.add_seconds (this.timeout, () => {
- dismiss ();
-
- return true;
+ notification_timeout_id = Timeout.add_seconds (this.timeout, () => {
+ dismissed ();
+ return Source.REMOVE;
});
- bool ok_pressed = false;
dismissed.connect ( () => {
- if (!ok_pressed && dismiss_func != null)
+ if (dismiss_func != null)
dismiss_func ();
+ set_reveal_child(false);
+ Source.remove(notification_timeout_id);
});
message_label.label = message;
@@ -51,20 +52,21 @@ private class Boxes.Notification: Gtk.Revealer {
ok_button_label.label = ok_label;
ok_button.clicked.connect ( () => {
- ok_pressed = true;
if (ok_func != null)
ok_func ();
- dismiss ();
+ set_reveal_child(false);
+ Source.remove(notification_timeout_id);
});
ok_button.show_all ();
}
- close_button.clicked.connect (dismiss);
+ close_button.clicked.connect ( () => {
+ dismissed();
+ });
}
- public void dismiss () {
- set_reveal_child (false);
- dismissed ();
+ public void dismiss() {
+ dismissed();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]