[Xfce4-commits] <xfconf:master> move dbus signal disconnection to XfconfChannel dispose (bug 5493)

Brian J. Tarricone brian at tarricone.org
Sat Sep 5 06:00:02 CEST 2009


Updating branch refs/heads/master
         to 0fe179d8fa21ceea20d548b7546dc9b0be943edb (commit)
       from c5161f07c455d7d6e8cc4f440600173845fdac0c (commit)

commit 0fe179d8fa21ceea20d548b7546dc9b0be943edb
Author: Brian J. Tarricone <brian at tarricone.org>
Date:   Fri Sep 4 20:55:55 2009 -0700

    move dbus signal disconnection to XfconfChannel dispose (bug 5493)
    
    patch from Nick Schermer <nick at xfce.org>.  the idea is that you can
    connect xfconf_shutdown() to a weak ref on the channel and everything
    will work ok.  since the weak ref callbacks run before the object's
    finalize function, shutting down xfconf before finalize would cause
    problems when the dbus signals would try to be disconnected in the
    finalize handler.

 xfconf/xfconf-channel.c |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/xfconf/xfconf-channel.c b/xfconf/xfconf-channel.c
index 5d3178a..1de89cb 100644
--- a/xfconf/xfconf-channel.c
+++ b/xfconf/xfconf-channel.c
@@ -54,7 +54,8 @@ struct _XfconfChannel
 {
     GObject parent;
 
-    gboolean is_singleton;
+    guint32 is_singleton:1,
+            disposed:1;
 
     gchar *channel_name;
     gchar *property_base;
@@ -96,6 +97,7 @@ static void xfconf_channel_get_g_property(GObject *object,
                                           guint property_id,
                                           GValue *value,
                                           GParamSpec *pspec);
+static void xfconf_channel_dispose(GObject *obj);
 static void xfconf_channel_finalize(GObject *obj);
 
 static void xfconf_channel_property_changed(XfconfCache *cache,
@@ -121,6 +123,7 @@ xfconf_channel_class_init(XfconfChannelClass *klass)
     object_class->constructor = xfconf_channel_constructor;
     object_class->set_property = xfconf_channel_set_g_property;
     object_class->get_property = xfconf_channel_get_g_property;
+    object_class->dispose = xfconf_channel_dispose;
     object_class->finalize = xfconf_channel_finalize;
 
     /**
@@ -319,14 +322,26 @@ xfconf_channel_get_g_property(GObject *object,
 }
 
 static void
-xfconf_channel_finalize(GObject *obj)
+xfconf_channel_dispose(GObject *obj)
 {
     XfconfChannel *channel = XFCONF_CHANNEL(obj);
 
-    g_signal_handlers_disconnect_by_func(channel->cache,
-                                         G_CALLBACK(xfconf_channel_property_changed),
-                                         channel);
-    g_object_unref(G_OBJECT(channel->cache));
+    if(!channel->disposed) {
+        channel->disposed = TRUE;
+
+        g_signal_handlers_disconnect_by_func(channel->cache,
+                                             G_CALLBACK(xfconf_channel_property_changed),
+                                             channel);
+        g_object_unref(G_OBJECT(channel->cache));
+
+        G_OBJECT_CLASS(xfconf_channel_parent_class)->dispose(obj);
+    }
+}
+
+static void
+xfconf_channel_finalize(GObject *obj)
+{
+    XfconfChannel *channel = XFCONF_CHANNEL(obj);
 
     g_free(channel->channel_name);
     g_free(channel->property_base);



More information about the Xfce4-commits mailing list