[gtk+/gtk-3-10] stack: Warn when setting a visible child which is not in the stack



commit 71affbeec0cca2cd6a01069dfd1c414a0079179b
Author: David King <dking redhat com>
Date:   Mon Oct 7 13:46:16 2013 +0100

    stack: Warn when setting a visible child which is not in the stack
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709613

 gtk/gtkstack.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 01e943e..be4e0ff 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -1278,7 +1278,11 @@ gtk_stack_set_visible_child (GtkStack  *stack,
 
   child_info = find_child_info_for_widget (stack, child);
   if (child_info == NULL)
-    return;
+    {
+      g_warning ("Given child of type '%s' not found in GtkStack",
+                 G_OBJECT_TYPE_NAME (child));
+      return;
+    }
 
   if (gtk_widget_get_visible (child_info->widget))
     set_visible_child (stack, child_info,
@@ -1343,7 +1347,13 @@ gtk_stack_set_visible_child_full (GtkStack               *stack,
         }
     }
 
-  if (child_info != NULL && gtk_widget_get_visible (child_info->widget))
+  if (child_info == NULL)
+    {
+      g_warning ("Child name '%s' not found in GtkStack", name);
+      return;
+    }
+
+  if (gtk_widget_get_visible (child_info->widget))
     set_visible_child (stack, child_info, transition, priv->transition_duration);
 }
 


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