[empathy/gnome-2-28] empathy-accounts-dialog: do_constructor: always return a new reference



commit ab6cdf918ec2d92cc5f4570c8657a3d36f4f9a9a
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu Oct 29 14:56:51 2009 +0100

    empathy-accounts-dialog: do_constructor: always return a new reference
    
    This fix is cleaner than the previous commmit. The constructor now
    always returns a new reference to the caller. It also now has an extra
    reference that it will release once the dialog as been destroyed.

 src/empathy-accounts-dialog.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 339b6c5..b138c81 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -1747,9 +1747,7 @@ do_constructor (GType type,
   if (dialog_singleton)
     {
       retval = G_OBJECT (dialog_singleton);
-      /* We don't ref the object as the caller is not suppose to unref it.
-       * The dialog is unreffed in accounts_dialog_destroy_cb when the window
-       * has been destroyed. */
+      g_object_ref (retval);
     }
   else
     {
@@ -1759,6 +1757,9 @@ do_constructor (GType type,
 
       dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval);
       g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton);
+      /* We add an extra reference that we'll release when the dialog is
+       * destroyed (accounts_dialog_destroy_cb) */
+      g_object_ref (retval);
     }
 
   return retval;
@@ -1897,6 +1898,9 @@ empathy_accounts_dialog_show (GtkWindow *parent,
     }
 
   gtk_window_present (GTK_WINDOW (priv->window));
+  /* EmpathyAccountsDialog kepts a ref on itself until the dialog is
+   * destroyed so we can release the ref returned by the constructor now. */
+  g_object_unref (dialog);
 
   return priv->window;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]