[gimp/gimp-2-10] app: fixes g_object_unref: assertion 'G_IS_OBJECT (object)' failed.



commit 199f9f13a5a25e20de6ddd53ef55c009cfe324d7
Author: Jehan <jehan girinstud io>
Date:   Wed Mar 20 14:02:11 2019 +0100

    app: fixes g_object_unref: assertion 'G_IS_OBJECT (object)' failed.
    
    "binding" data can be set to NULL. Do not assume it is a proper object.
    
    Also I was tempted to use g_object_set_data() to simply free the
    GBinding object on setting a new data, but such object will also be
    freed when the widget is destroyed by default. So that would also end up
    in double destruction. Instead just keep current logics.
    
    This CRITICAL was reported in #3133 but this is not the main bug.
    
    (cherry picked from commit af6760b3c95694f33455a2d542eb9cb817290bde)

 app/propgui/gimppropgui-generic.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/app/propgui/gimppropgui-generic.c b/app/propgui/gimppropgui-generic.c
index 020c5e260b..eb40635d33 100644
--- a/app/propgui/gimppropgui-generic.c
+++ b/app/propgui/gimppropgui-generic.c
@@ -276,27 +276,21 @@ static void
 gimp_prop_gui_chain_toggled (GimpChainButton *chain,
                              GtkAdjustment   *x_adj)
 {
+  GBinding      *binding;
   GtkAdjustment *y_adj;
 
   y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
 
   if (gimp_chain_button_get_active (chain))
     {
-      GBinding *binding;
-
       binding = g_object_bind_property (x_adj, "value",
                                         y_adj, "value",
                                         G_BINDING_BIDIRECTIONAL);
-
-      g_object_set_data (G_OBJECT (chain), "binding", binding);
     }
   else
     {
-      GBinding *binding;
-
       binding = g_object_get_data (G_OBJECT (chain), "binding");
-
-      g_object_unref (binding);
-      g_object_set_data (G_OBJECT (chain), "binding", NULL);
+      g_clear_object (&binding);
     }
+  g_object_set_data (G_OBJECT (chain), "binding", binding);
 }


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