[gtk+/wip/checked] widget: Add checks for setting state flags



commit c1dc9d341f924744a670315fd70640cec8dc4a03
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 15 16:51:42 2014 +0200

    widget: Add checks for setting state flags
    
    This is more for GTK developers to catch when they forgot to change
    GTK_STATE_FLAGS_BITS after adding a new state flag than to prevent
    widget developers from using the wrong flags.

 gtk/gtkwidget.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d2cf6b1..1d9dc14 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8790,6 +8790,7 @@ gtk_widget_set_state_flags (GtkWidget     *widget,
 #define ALLOWED_FLAGS (~(GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL))
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (flags < (1 << GTK_STATE_FLAGS_BITS));
 
   if ((!clear && (widget->priv->state_flags & flags) == flags) ||
       (clear && widget->priv->state_flags == flags))
@@ -8819,6 +8820,7 @@ gtk_widget_unset_state_flags (GtkWidget     *widget,
                               GtkStateFlags  flags)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (flags < (1 << GTK_STATE_FLAGS_BITS));
 
   if ((widget->priv->state_flags & flags) == 0)
     return;


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