SidebarRow: Unref CloudProvider on change/finalize
authorDaniel Boles <dboles@src.gnome.org>
Tue, 12 Sep 2017 20:56:46 +0000 (21:56 +0100)
committerDaniel Boles <dboles@src.gnome.org>
Mon, 18 Sep 2017 17:20:02 +0000 (18:20 +0100)
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

index cfa28b580fc8d9cc5a123bda32d23a1e3f986df3..20ef9a5729a8eff08d79f4d2dc9357db51f25556 100644 (file)
@@ -267,15 +267,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:
       {
@@ -297,6 +292,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,
@@ -403,6 +399,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);
 }