aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-08-11 17:17:57 -0500
committerCharles Kerr <charles.kerr@canonical.com>2015-08-11 17:17:57 -0500
commit8301d866b4a4aa7ef9f9235ebcb56c121b71b495 (patch)
tree0fa02d31c50d6aaecf37cf0a754715fc7b9f4d17 /src
parent93ed4338dc83fcae4a7c743452cf275d19d1d16c (diff)
downloadayatana-indicator-sound-8301d866b4a4aa7ef9f9235ebcb56c121b71b495.tar.gz
ayatana-indicator-sound-8301d866b4a4aa7ef9f9235ebcb56c121b71b495.tar.bz2
ayatana-indicator-sound-8301d866b4a4aa7ef9f9235ebcb56c121b71b495.zip
fix circular reference loop that prevented Service from being destructed properly
Diffstat (limited to 'src')
-rw-r--r--src/service.vala42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/service.vala b/src/service.vala
index 777070a..a8e11fd 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -40,20 +40,7 @@ public class IndicatorSound.Service: Object {
warn_notification.set_hint ("x-canonical-non-shaped-icon", "true");
warn_notification.set_hint ("x-canonical-snap-decisions", "true");
warn_notification.set_hint ("x-canonical-private-affirmative-tint", "true");
- warn_notification.add_action ("ok", _("OK"), (n, a) => {
- stop_clamp_to_high_timeout();
- volume_control.approve_high_volume ();
- if (_pre_warn_volume != null) {
- var tmp = _pre_warn_volume;
- _pre_warn_volume = null;
- volume_control.volume = tmp;
- }
- });
- warn_notification.add_action ("cancel", _("Cancel"), (n, a) => {
- _pre_warn_volume = null;
- });
-
-
+ warn_notification.closed.connect((n) => { n.clear_actions(); });
BusWatcher.watch_namespace (GLib.BusType.SESSION,
"org.freedesktop.Notifications",
() => { debug("Notifications name appeared"); notify_server_caps_checked = false; },
@@ -131,7 +118,8 @@ public class IndicatorSound.Service: Object {
}
private void close_notification(Notify.Notification? n) {
- if ((n != null) && (n.id != 0)) {
+ return_if_fail (n != null);
+ if (n.id != 0) {
try {
n.close();
} catch (GLib.Error e) {
@@ -141,12 +129,11 @@ public class IndicatorSound.Service: Object {
}
private void show_notification(Notify.Notification? n) {
- if (n != null) {
- try {
- n.show ();
- } catch (GLib.Error e) {
- warning ("Unable to show notification: %s", e.message);
- }
+ return_if_fail (n != null);
+ try {
+ n.show ();
+ } catch (GLib.Error e) {
+ warning ("Unable to show notification: %s", e.message);
}
}
@@ -311,6 +298,19 @@ public class IndicatorSound.Service: Object {
_pre_warn_volume.volume = volume_control.volume.volume;
_pre_warn_volume.reason = volume_control.volume.reason;
}
+ warn_notification.clear_actions();
+ warn_notification.add_action ("ok", _("OK"), (n, a) => {
+ stop_clamp_to_high_timeout();
+ volume_control.approve_high_volume ();
+ if (_pre_warn_volume != null) {
+ var tmp = _pre_warn_volume;
+ _pre_warn_volume = null;
+ volume_control.volume = tmp;
+ }
+ });
+ warn_notification.add_action ("cancel", _("Cancel"), (n, a) => {
+ _pre_warn_volume = null;
+ });
show_notification(warn_notification);
} else {
close_notification(warn_notification);