[gtk+] SidebarRow: Unref CloudProvider on change/finalize



commit 383fa87993b590f0ee1d36c70e9e949679ddc4b5
Author: Daniel Boles <dboles src gnome org>
Date:   Tue Sep 12 21:56:46 2017 +0100

    SidebarRow: Unref CloudProvider on change/finalize
    
    It was never unref()d, either when replacing the existing GObject in
    set_property(), cleaning up in finalize(), or becoming a placeholder.
    
    Fix by using g_set_object() and g_clear_object() to unref as needed.
    
    This also drops the check that the newly set object is a valid cloud
    provider account, as we don’t do the equivalent for any of the other
    object-typed properties, and Carlos didn’t think this was important.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787600

 gtk/gtksidebarrow.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c
index 6939bf5..65a69f5 100644
--- a/gtk/gtksidebarrow.c
+++ b/gtk/gtksidebarrow.c
@@ -266,15 +266,10 @@ gtk_sidebar_row_set_property (GObject      *object,
       break;
 
     case PROP_CLOUD_PROVIDER:
-      {
 #ifdef HAVE_CLOUDPROVIDERS
-        gpointer *object;
-        object = g_value_get_object (value);
-        if (IS_CLOUD_PROVIDER_ACCOUNT(object))
-          self->cloud_provider = g_object_ref (object);
+      g_set_object (&self->cloud_provider, g_value_get_object (value));
 #endif
-        break;
-      }
+      break;
 
     case PROP_PLACEHOLDER:
       {
@@ -296,6 +291,7 @@ gtk_sidebar_row_set_property (GObject      *object,
             g_clear_object (&self->drive);
             g_clear_object (&self->volume);
             g_clear_object (&self->mount);
+            g_clear_object (&self->cloud_provider);
 
             gtk_container_foreach (GTK_CONTAINER (self),
                                    (GtkCallback) gtk_widget_destroy,
@@ -402,6 +398,7 @@ gtk_sidebar_row_finalize (GObject *object)
   g_clear_object (&self->drive);
   g_clear_object (&self->volume);
   g_clear_object (&self->mount);
+  g_clear_object (&self->cloud_provider);
 
   G_OBJECT_CLASS (gtk_sidebar_row_parent_class)->finalize (object);
 }


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