[geary] Fix warning/crash when libnotify enabled and server is not present. Bug 768911.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Fix warning/crash when libnotify enabled and server is not present. Bug 768911.
- Date: Mon, 18 Jul 2016 12:13:42 +0000 (UTC)
commit 8c22ce67270cc6e5f5401c48dda22a525e765a9b
Author: Michael James Gratton <mike vee net>
Date: Mon Jul 18 13:51:40 2016 +1000
Fix warning/crash when libnotify enabled and server is not present. Bug 768911.
* src/client/notification/libnotify.vala (Libnotify): Allow for the
server capabilities being null.
bindings/vapi/libnotify.vapi | 2 +-
src/client/notification/libnotify.vala | 11 ++++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/bindings/vapi/libnotify.vapi b/bindings/vapi/libnotify.vapi
index c5a6751..163cff1 100644
--- a/bindings/vapi/libnotify.vapi
+++ b/bindings/vapi/libnotify.vapi
@@ -59,7 +59,7 @@ namespace Notify {
[CCode (cheader_filename = "libnotify/notify.h")]
public static unowned string get_app_name ();
[CCode (cheader_filename = "libnotify/notify.h")]
- public static GLib.List<string> get_server_caps ();
+ public static GLib.List<string>? get_server_caps ();
[CCode (cheader_filename = "libnotify/notify.h")]
public static bool get_server_info (out unowned string ret_name, out unowned string ret_vendor, out
unowned string ret_version, out unowned string ret_spec_version);
[CCode (cheader_filename = "libnotify/notify.h")]
diff --git a/src/client/notification/libnotify.vala b/src/client/notification/libnotify.vala
index bb25268..3f405e0 100644
--- a/src/client/notification/libnotify.vala
+++ b/src/client/notification/libnotify.vala
@@ -16,7 +16,7 @@ public class Libnotify : Geary.BaseObject {
private Notify.Notification? error_notification = null;
private Geary.Folder? folder = null;
private Geary.Email? email = null;
- private List<string> caps;
+ private List<string>? caps = null;
public signal void invoked(Geary.Folder? folder, Geary.Email? email);
@@ -31,8 +31,10 @@ public class Libnotify : Geary.BaseObject {
}
init_sound();
- caps = Notify.get_server_caps();
+ // This will return null if no notification server is present
+ this.caps = Notify.get_server_caps();
+
monitor.new_messages_arrived.connect(on_new_messages_arrived);
}
@@ -148,8 +150,11 @@ public class Libnotify : Geary.BaseObject {
}
- private Notify.Notification issue_notification(string category, string summary,
+ private Notify.Notification? issue_notification(string category, string summary,
string body, Gdk.Pixbuf? icon, string? sound) {
+ if (this.caps == null)
+ return null;
+
// Avoid constructor due to ABI change
Notify.Notification notification = (Notify.Notification) GLib.Object.new(
typeof (Notify.Notification),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]