From 2d75d27b427c25cc892ccd204caec4696eb9864a Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 14 May 2014 15:45:23 +0200 Subject: [PATCH] Tp*Context:dbus-context is now an object Keep a ref on it to be safe. Fix https://bugs.freedesktop.org/show_bug.cgi?id=77143 --- telepathy-glib/add-dispatch-operation-context.c | 11 +++++++---- telepathy-glib/handle-channel-context.c | 11 +++++++---- telepathy-glib/observe-channel-context.c | 11 +++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/telepathy-glib/add-dispatch-operation-context.c b/telepathy-glib/add-dispatch-operation-context.c index ebaec36..48f6b4a 100644 --- a/telepathy-glib/add-dispatch-operation-context.c +++ b/telepathy-glib/add-dispatch-operation-context.c @@ -142,6 +142,8 @@ tp_add_dispatch_operation_context_dispose (GObject *object) self->priv->result = NULL; } + g_clear_object (&self->priv->dbus_context); + if (dispose != NULL) dispose (object); } @@ -207,7 +209,7 @@ tp_add_dispatch_operation_context_set_property (GObject *object, break; case PROP_DBUS_CONTEXT: - self->priv->dbus_context = g_value_get_pointer (value); + self->priv->dbus_context = g_value_dup_object (value); break; default: @@ -330,8 +332,9 @@ tp_add_dispatch_operation_context_class_init ( * * Since: 0.11.5 */ - param_spec = g_param_spec_pointer ("dbus-context", "D-Bus context", + param_spec = g_param_spec_object ("dbus-context", "D-Bus context", "The GDBusMethodInvocation associated with the AddDispatchOperation call", + G_TYPE_DBUS_METHOD_INVOCATION, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_DBUS_CONTEXT, param_spec); @@ -374,7 +377,7 @@ tp_add_dispatch_operation_context_accept (TpAddDispatchOperationContext *self) self->priv->state = TP_ADD_DISPATCH_OPERATION_CONTEXT_STATE_DONE; g_dbus_method_invocation_return_value (self->priv->dbus_context, NULL); - self->priv->dbus_context = NULL; + g_clear_object (&self->priv->dbus_context); } /** @@ -398,7 +401,7 @@ tp_add_dispatch_operation_context_fail (TpAddDispatchOperationContext *self, self->priv->state = TP_ADD_DISPATCH_OPERATION_CONTEXT_STATE_FAILED; g_dbus_method_invocation_return_gerror (self->priv->dbus_context, error); - self->priv->dbus_context = NULL; + g_clear_object (&self->priv->dbus_context); } /** diff --git a/telepathy-glib/handle-channel-context.c b/telepathy-glib/handle-channel-context.c index 1b3cc43..331d9df 100644 --- a/telepathy-glib/handle-channel-context.c +++ b/telepathy-glib/handle-channel-context.c @@ -160,6 +160,8 @@ tp_handle_channel_context_dispose (GObject *object) self->priv->result = NULL; } + g_clear_object (&self->priv->dbus_context); + if (dispose != NULL) dispose (object); } @@ -243,7 +245,7 @@ tp_handle_channel_context_set_property (GObject *object, break; case PROP_DBUS_CONTEXT: - self->priv->dbus_context = g_value_get_pointer (value); + self->priv->dbus_context = g_value_dup_object (value); break; default: @@ -404,8 +406,9 @@ tp_handle_channel_context_class_init ( * * Since: 0.11.6 */ - param_spec = g_param_spec_pointer ("dbus-context", "D-Bus context", + param_spec = g_param_spec_object ("dbus-context", "D-Bus context", "The GDBusMethodInvocation associated with the HandleChannels call", + G_TYPE_DBUS_METHOD_INVOCATION, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_DBUS_CONTEXT, param_spec); @@ -477,7 +480,7 @@ tp_handle_channel_context_accept (TpHandleChannelContext *self) self->priv->state = TP_HANDLE_CHANNEL_CONTEXT_STATE_DONE; g_dbus_method_invocation_return_value (self->priv->dbus_context, NULL); - self->priv->dbus_context = NULL; + g_clear_object (&self->priv->dbus_context); g_signal_emit (self, signals[SIGNAL_DONE], 0); } @@ -503,7 +506,7 @@ tp_handle_channel_context_fail (TpHandleChannelContext *self, self->priv->state = TP_HANDLE_CHANNEL_CONTEXT_STATE_FAILED; g_dbus_method_invocation_return_gerror (self->priv->dbus_context, error); - self->priv->dbus_context = NULL; + g_clear_object (&self->priv->dbus_context); } /** diff --git a/telepathy-glib/observe-channel-context.c b/telepathy-glib/observe-channel-context.c index 21b55cc..1c0f879 100644 --- a/telepathy-glib/observe-channel-context.c +++ b/telepathy-glib/observe-channel-context.c @@ -153,6 +153,8 @@ tp_observe_channel_context_dispose (GObject *object) self->priv->result = NULL; } + g_clear_object (&self->priv->dbus_context); + if (dispose != NULL) dispose (object); } @@ -218,7 +220,7 @@ tp_observe_channel_context_set_property (GObject *object, g_ptr_array_foreach (self->requests, (GFunc) g_object_ref, NULL); break; case PROP_DBUS_CONTEXT: - self->priv->dbus_context = g_value_get_pointer (value); + self->priv->dbus_context = g_value_dup_object (value); break; case PROP_OBSERVER_INFO: self->observer_info = g_value_dup_variant (value); @@ -361,8 +363,9 @@ tp_observe_channel_context_class_init (TpObserveChannelContextClass *cls) * * Since: 0.11.5 */ - param_spec = g_param_spec_pointer ("dbus-context", "D-Bus context", + param_spec = g_param_spec_object ("dbus-context", "D-Bus context", "The GDBusMethodInvocation associated with the ObserveChannels call", + G_TYPE_DBUS_METHOD_INVOCATION, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_DBUS_CONTEXT, param_spec); @@ -431,7 +434,7 @@ tp_observe_channel_context_accept (TpObserveChannelContext *self) self->priv->state = TP_OBSERVE_CHANNEL_CONTEXT_STATE_DONE; g_dbus_method_invocation_return_value (self->priv->dbus_context, NULL); - self->priv->dbus_context = NULL; + g_clear_object (&self->priv->dbus_context); } /** @@ -454,7 +457,7 @@ tp_observe_channel_context_fail (TpObserveChannelContext *self, self->priv->state = TP_OBSERVE_CHANNEL_CONTEXT_STATE_FAILED; g_dbus_method_invocation_return_gerror (self->priv->dbus_context, error); - self->priv->dbus_context = NULL; + g_clear_object (&self->priv->dbus_context); } /** -- 1.9.0