From 1e2e58705c0dbda29a6bbe9fb890b7700fee428e Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Fri, 8 Apr 2011 16:12:33 -0400 Subject: [PATCH] GDBusProxy: Store GDBusObject in private struct instead of qdata Signed-off-by: David Zeuthen --- gio/gdbusproxy.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c index 2e95f9218..271610032 100644 --- a/gio/gdbusproxy.c +++ b/gio/gdbusproxy.c @@ -105,6 +105,8 @@ struct _GDBusProxyPrivate guint signals_subscriber_id; gboolean initialized; + + GDBusObject *object; }; enum @@ -174,6 +176,9 @@ g_dbus_proxy_finalize (GObject *object) g_dbus_interface_info_unref (proxy->priv->expected_interface); } + if (proxy->priv->object != NULL) + g_object_remove_weak_pointer (G_OBJECT (proxy->priv->object), (gpointer *) &proxy->priv->object); + G_OBJECT_CLASS (g_dbus_proxy_parent_class)->finalize (object); } @@ -2551,7 +2556,6 @@ g_dbus_proxy_call_sync (GDBusProxy *proxy, } /* ---------------------------------------------------------------------------------------------------- */ -/* Hack until this is merged into libgio (extending types at run-time isn't really safe in any way) */ static GDBusInterfaceInfo * _g_dbus_proxy_get_info (GDBusInterface *interface) @@ -2563,16 +2567,20 @@ _g_dbus_proxy_get_info (GDBusInterface *interface) static GDBusObject * _g_dbus_proxy_get_object (GDBusInterface *interface) { - /* TODO */ - return g_object_get_data (G_OBJECT (interface), "-x-gdbus-binding-tool-object"); + GDBusProxy *proxy = G_DBUS_PROXY (interface); + return proxy->priv->object; } static void _g_dbus_proxy_set_object (GDBusInterface *interface, GDBusObject *object) { - /* TODO */ - g_object_set_data (G_OBJECT (interface), "-x-gdbus-binding-tool-object", object); + GDBusProxy *proxy = G_DBUS_PROXY (interface); + if (proxy->priv->object != NULL) + g_object_remove_weak_pointer (G_OBJECT (proxy->priv->object), (gpointer *) &proxy->priv->object); + proxy->priv->object = object; + if (proxy->priv->object != NULL) + g_object_add_weak_pointer (G_OBJECT (proxy->priv->object), (gpointer *) &proxy->priv->object); } static void