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.
This commit is contained in:
Jehan 2019-03-20 14:02:11 +01:00
parent 7cf06c3f60
commit af6760b3c9
1 changed files with 3 additions and 9 deletions

View File

@ -276,27 +276,21 @@ static void
gimp_prop_gui_chain_toggled (GimpChainButton *chain, gimp_prop_gui_chain_toggled (GimpChainButton *chain,
GtkAdjustment *x_adj) GtkAdjustment *x_adj)
{ {
GBinding *binding;
GtkAdjustment *y_adj; GtkAdjustment *y_adj;
y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment"); y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
if (gimp_chain_button_get_active (chain)) if (gimp_chain_button_get_active (chain))
{ {
GBinding *binding;
binding = g_object_bind_property (x_adj, "value", binding = g_object_bind_property (x_adj, "value",
y_adj, "value", y_adj, "value",
G_BINDING_BIDIRECTIONAL); G_BINDING_BIDIRECTIONAL);
g_object_set_data (G_OBJECT (chain), "binding", binding);
} }
else else
{ {
GBinding *binding;
binding = g_object_get_data (G_OBJECT (chain), "binding"); binding = g_object_get_data (G_OBJECT (chain), "binding");
g_clear_object (&binding);
g_object_unref (binding);
g_object_set_data (G_OBJECT (chain), "binding", NULL);
} }
g_object_set_data (G_OBJECT (chain), "binding", binding);
} }