[gtk+/gtk-2-24] Fixed: If can’t add child, don’t add to child info



commit 292e023c833b810580f546710fcf298ee50b99c2
Author: Daniel Boles <dboles src gnome org>
Date:   Fri Oct 13 09:56:17 2017 +0100

    Fixed: If can’t add child, don’t add to child info
    
    If the call to set_parent() failed, we were still adding the child to
    the internal list of children, despite that it was not really added.
    That meant we could later try to do invalid stuff with that non-child.
    
    Fix that by asserting and giving up if the child that the user is
    attempting to add is already parented.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701296

 gtk/gtkfixed.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c
index 3106e1f..6b4ee37 100644
--- a/gtk/gtkfixed.c
+++ b/gtk/gtkfixed.c
@@ -156,6 +156,7 @@ gtk_fixed_put (GtkFixed       *fixed,
 
   g_return_if_fail (GTK_IS_FIXED (fixed));
   g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (gtk_widget_get_parent (widget) == NULL);
 
   child_info = g_new (GtkFixedChild, 1);
   child_info->widget = widget;


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