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.
This commit is contained in:
Jehan 2019-03-20 15:05:22 +01:00
parent 03dc24455a
commit 9042e85f3c
1 changed files with 6 additions and 5 deletions

View File

@ -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);