Don't try to use the proxy after it is destroyed
https://bugzilla.gnome.org/show_bug.cgi?id=608089
This commit is contained in:
parent
eed6a066cf
commit
d6476d362b
|
@ -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,
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue