[gimp] app: make gimp_prop_gui_chain_toggled() less error-prone.



commit 9042e85f3c4b000a3f1f43ad09c1f97e6418c999
Author: Jehan <jehan girinstud io>
Date:   Wed Mar 20 15:05:22 2019 +0100

    app: make gimp_prop_gui_chain_toggled() less error-prone.
    
    Don't assume that "toggled" signal means that toggle status actually
    changed.
    
    Though issue #3133 got fixed with my previous commit, let's make sure we
    never create several GBinding for the same GimpChain by always checking
    existence of a previous one after a "toggled" signal.
    Also only create a GBinding object if one doesn't already exist.

 app/propgui/gimppropgui-generic.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/app/propgui/gimppropgui-generic.c b/app/propgui/gimppropgui-generic.c
index eb40635d33..43529bff1a 100644
--- a/app/propgui/gimppropgui-generic.c
+++ b/app/propgui/gimppropgui-generic.c
@@ -279,17 +279,18 @@ gimp_prop_gui_chain_toggled (GimpChainButton *chain,
   GBinding      *binding;
   GtkAdjustment *y_adj;
 
-  y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
+  binding = g_object_get_data (G_OBJECT (chain), "binding");
+  y_adj   = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
 
   if (gimp_chain_button_get_active (chain))
     {
-      binding = g_object_bind_property (x_adj, "value",
-                                        y_adj, "value",
-                                        G_BINDING_BIDIRECTIONAL);
+      if (! binding)
+        binding = g_object_bind_property (x_adj, "value",
+                                          y_adj, "value",
+                                          G_BINDING_BIDIRECTIONAL);
     }
   else
     {
-      binding = g_object_get_data (G_OBJECT (chain), "binding");
       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]