Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,25 @@ public static class Global {
private const string interface_name = "org.freedesktop.Notifications";
private const string object_path = "/org/freedesktop/Notifications";

private static INotifications dbus_object = null;
private static volatile INotifications dbus_object = null;
private static object dbus_object_lock = new object ();

internal static INotifications DBusObject {
get {
if (dbus_object != null)
return dbus_object;
if (dbus_object == null) {
lock (dbus_object_lock) {
if (dbus_object == null) {
if (! Bus.Session.NameHasOwner (interface_name)) {
Bus.Session.StartServiceByName (interface_name);
}

lock (dbus_object_lock) {
if (! Bus.Session.NameHasOwner (interface_name))
Bus.Session.StartServiceByName (interface_name);

dbus_object = Bus.Session.GetObject<INotifications>
(interface_name, new ObjectPath (object_path));
return dbus_object;
dbus_object = Bus.Session.GetObject<INotifications>
(interface_name, new ObjectPath (object_path));
}
}
}

return dbus_object;
}
}

Expand All @@ -85,7 +88,7 @@ public static string[] Capabilities {
return DBusObject.Capabilities;
}
}

public static ServerInformation ServerInformation {
get {
return DBusObject.ServerInformation;
Expand Down