diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2010-08-19 10:06:53 +0200 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2010-08-19 11:15:39 +0200 |
commit | 80c02d9a756773ffafbccd8b2577c5cfc218ac59 (patch) | |
tree | de2a9f26be024b889230f176bbebff225312d102 /src/server-tls-manager.c | |
parent | d66c7bc68db56c5c7ddb45ae876773b2c60a71f1 (diff) | |
download | telepathy-gabble-80c02d9a756773ffafbccd8b2577c5cfc218ac59.tar.gz |
Own a rerefence to the GabbleConnection
We will clear our reference either when the connection goes DISCONNECTED
or when the channel manager is disposed.
In both cases, tp_clear_object() will take care of doing it right for
us.
Diffstat (limited to 'src/server-tls-manager.c')
-rw-r--r-- | src/server-tls-manager.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/server-tls-manager.c b/src/server-tls-manager.c index 3172475be..f5c2f4a87 100644 --- a/src/server-tls-manager.c +++ b/src/server-tls-manager.c @@ -57,6 +57,8 @@ struct _GabbleServerTLSManagerPrivate { gboolean verify_async_called; gboolean tls_state_changed; + + gboolean dispose_has_run; }; static void @@ -89,7 +91,7 @@ gabble_server_tls_manager_set_property (GObject *object, switch (property_id) { case PROP_CONNECTION: - self->priv->connection = g_value_get_object (value); + self->priv->connection = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -107,9 +109,13 @@ connection_status_changed_cb (GabbleConnection *conn, DEBUG ("Connection status changed, now %d", status); - if (status == TP_CONNECTION_STATUS_DISCONNECTED && - self->priv->channel != NULL) - gabble_server_tls_channel_close (self->priv->channel); + if (status == TP_CONNECTION_STATUS_DISCONNECTED) + { + if (self->priv->channel != NULL) + gabble_server_tls_channel_close (self->priv->channel); + + tp_clear_object (&self->priv->connection); + } } static void @@ -247,6 +253,21 @@ gabble_server_tls_manager_init (GabbleServerTLSManager *self) } static void +gabble_server_tls_manager_dispose (GObject *object) +{ + GabbleServerTLSManager *self = GABBLE_SERVER_TLS_MANAGER (object); + + if (self->priv->dispose_has_run) + return; + + self->priv->dispose_has_run = TRUE; + + tp_clear_object (&self->priv->connection); + + G_OBJECT_CLASS (gabble_server_tls_manager_parent_class)->dispose (object); +} + +static void gabble_server_tls_manager_finalize (GObject *object) { GabbleServerTLSManager *self = GABBLE_SERVER_TLS_MANAGER (object); @@ -284,7 +305,8 @@ gabble_server_tls_manager_class_init (GabbleServerTLSManagerClass *klass) g_type_class_add_private (klass, sizeof (GabbleServerTLSManagerPrivate)); - oclass->dispose = gabble_server_tls_manager_finalize; + oclass->dispose = gabble_server_tls_manager_dispose; + oclass->finalize = gabble_server_tls_manager_finalize; oclass->constructed = gabble_server_tls_manager_constructed; oclass->set_property = gabble_server_tls_manager_set_property; oclass->get_property = gabble_server_tls_manager_get_property; |