summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Jon McCann <jmccann@redhat.com>2010-06-24 01:42:18 -0400
committerWilliam Jon McCann <jmccann@redhat.com>2010-06-24 02:11:53 -0400
commitd6476d362b807f8bf06e56cbe17d6b3c817e665e (patch)
tree31421f88d26f50dc01c120ecbb95f8461d651f91
parenteed6a066cfbea1427f24763e985dd36e23179eec (diff)
downloadlibnotify-d6476d362b807f8bf06e56cbe17d6b3c817e665e.tar.gz
Don't try to use the proxy after it is destroyed
https://bugzilla.gnome.org/show_bug.cgi?id=608089
-rw-r--r--libnotify/notification.c38
-rw-r--r--libnotify/notify.c26
2 files changed, 58 insertions, 6 deletions
diff --git a/libnotify/notification.c b/libnotify/notification.c
index c992349..fa45c1e 100644
--- a/libnotify/notification.c
+++ b/libnotify/notification.c
@@ -404,7 +404,7 @@ notify_notification_finalize (GObject *object)
g_object_remove_weak_pointer (G_OBJECT (priv->status_icon),
(gpointer) & priv->status_icon);
- if (priv->signals_registered) {
+ if (proxy != NULL && priv->signals_registered) {
dbus_g_proxy_disconnect_signal (proxy,
"NotificationClosed",
G_CALLBACK (_close_signal_handler),
@@ -734,6 +734,24 @@ _gslist_to_string_array (GSList *list)
return (char **) g_array_free (a, FALSE);
}
+static void
+on_proxy_destroy (DBusGProxy *proxy,
+ NotifyNotification *notification)
+{
+ if (notification->priv->signals_registered) {
+ dbus_g_proxy_disconnect_signal (proxy,
+ "NotificationClosed",
+ G_CALLBACK (_close_signal_handler),
+ notification);
+ dbus_g_proxy_disconnect_signal (proxy,
+ "ActionInvoked",
+ G_CALLBACK (_action_signal_handler),
+ notification);
+ notification->priv->signals_registered = FALSE;
+ }
+}
+
+
/**
* notify_notification_show:
* @notification: The notification.
@@ -759,8 +777,17 @@ notify_notification_show (NotifyNotification *notification,
priv = notification->priv;
proxy = _notify_get_g_proxy ();
+ if (proxy == NULL) {
+ g_set_error (error, 0, 0, "Unable to connect to server");
+ return FALSE;
+ }
if (!priv->signals_registered) {
+ g_signal_connect (proxy,
+ "destroy",
+ G_CALLBACK (on_proxy_destroy),
+ notification);
+
dbus_g_proxy_connect_signal (proxy,
"NotificationClosed",
G_CALLBACK (_close_signal_handler),
@@ -1308,6 +1335,7 @@ notify_notification_close (NotifyNotification *notification,
{
NotifyNotificationPrivate *priv;
GError *tmp_error = NULL;
+ DBusGProxy *proxy;
g_return_val_if_fail (notification != NULL, FALSE);
g_return_val_if_fail (NOTIFY_IS_NOTIFICATION (notification), FALSE);
@@ -1315,7 +1343,13 @@ notify_notification_close (NotifyNotification *notification,
priv = notification->priv;
- dbus_g_proxy_call (_notify_get_g_proxy (),
+ proxy = _notify_get_g_proxy ();
+ if (proxy == NULL) {
+ g_set_error (error, 0, 0, "Unable to connect to server");
+ return FALSE;
+ }
+
+ dbus_g_proxy_call (proxy,
"CloseNotification",
&tmp_error,
G_TYPE_UINT,
diff --git a/libnotify/notify.c b/libnotify/notify.c
index ccc3ed3..beba480 100644
--- a/libnotify/notify.c
+++ b/libnotify/notify.c
@@ -159,6 +159,13 @@ _notify_get_dbus_g_conn (void)
return _dbus_gconn;
}
+static void
+on_proxy_destroy (DBusGProxy *proxy,
+ gpointer data)
+{
+ _proxy = NULL;
+}
+
DBusGProxy *
_notify_get_g_proxy (void)
{
@@ -183,6 +190,11 @@ _notify_get_g_proxy (void)
NOTIFY_DBUS_CORE_INTERFACE);
dbus_g_connection_unref (bus);
+ g_signal_connect (_proxy,
+ "destroy",
+ G_CALLBACK (on_proxy_destroy),
+ NULL);
+
dbus_g_object_register_marshaller (notify_marshal_VOID__UINT_UINT,
G_TYPE_NONE,
G_TYPE_UINT,
@@ -226,9 +238,12 @@ notify_get_server_caps (void)
char **caps = NULL;
char **cap;
GList *result = NULL;
- DBusGProxy *proxy = _notify_get_g_proxy ();
+ DBusGProxy *proxy;
- g_return_val_if_fail (proxy != NULL, NULL);
+ proxy = _notify_get_g_proxy ();
+ if (proxy == NULL) {
+ return NULL;
+ }
if (!dbus_g_proxy_call (proxy,
"GetCapabilities",
@@ -273,13 +288,16 @@ notify_get_server_info (char **ret_name,
char **ret_spec_version)
{
GError *error = NULL;
- DBusGProxy *proxy = _notify_get_g_proxy ();
+ DBusGProxy *proxy;
char *name;
char *vendor;
char *version;
char *spec_version;
- g_return_val_if_fail (proxy != NULL, FALSE);
+ proxy = _notify_get_g_proxy ();
+ if (proxy == NULL) {
+ return FALSE;
+ }
if (!dbus_g_proxy_call (proxy,
"GetServerInformation",