]> git.0d.be Git - empathy.git/commitdiff
Unref the connection if it fails to become ready or is invalidated
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 29 Jul 2009 17:28:56 +0000 (19:28 +0200)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 29 Jul 2009 17:44:03 +0000 (19:44 +0200)
libempathy/empathy-account.c

index db2ca1f5613d9eca17dedeeefbfcfa35be9bc1f5..5cf489769969d90140c4688c8e125d31556abaaa 100644 (file)
@@ -607,6 +607,21 @@ empathy_account_class_init (EmpathyAccountClass *empathy_account_class)
     G_TYPE_NONE, 0);
 }
 
+static void
+empathy_account_free_connection (EmpathyAccount *account)
+{
+  EmpathyAccountPriv *priv = GET_PRIV (account);
+
+  if (priv->connection_invalidated_id != 0)
+    g_signal_handler_disconnect (priv->connection,
+        priv->connection_invalidated_id);
+  priv->connection_invalidated_id = 0;
+
+  if (priv->connection != NULL)
+    g_object_unref (priv->connection);
+  priv->connection = NULL;
+}
+
 void
 empathy_account_dispose (GObject *object)
 {
@@ -618,14 +633,7 @@ empathy_account_dispose (GObject *object)
 
   priv->dispose_has_run = TRUE;
 
-  if (priv->connection_invalidated_id != 0)
-    g_signal_handler_disconnect (priv->connection,
-        priv->connection_invalidated_id);
-  priv->connection_invalidated_id = 0;
-
-  if (priv->connection != NULL)
-    g_object_unref (priv->connection);
-  priv->connection = NULL;
+  empathy_account_free_connection (self);
 
   /* release any references held by the object here */
   if (G_OBJECT_CLASS (empathy_account_parent_class)->dispose != NULL)
@@ -785,13 +793,12 @@ empathy_account_connection_ready_cb (TpConnection *connection,
     gpointer user_data)
 {
   EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
-  EmpathyAccountPriv *priv = GET_PRIV (account);
 
   if (error != NULL)
     {
       DEBUG ("(%s) Connection failed to become ready: %s",
         empathy_account_get_unique_name (account), error->message);
-      priv->connection = NULL;
+      empathy_account_free_connection (account);
     }
   else
     {