[gtk+] stylecontext: Always warn on style mismatch



commit a9814fea7d169400b033bc28f3b7570b3423bc15
Author: Benjamin Otte <otte redhat com>
Date:   Fri Nov 6 18:57:24 2015 +0100

    stylecontext: Always warn on style mismatch
    
    For now, always warn when
    gtk_style_context_get()/get_padding()/get_margin()/get_border()
    get called with the wrong state.
    
    We used to hide this behind an env var because the warnings were
    too frequent, but with the recent refactorings, this warning has become
    rather important for detecting bugs.
    
    If it's still problematic, we might want to revert this patch before
    3.20.

 gtk/gtkstylecontext.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index e5fa5f2..46be12c 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -490,27 +490,25 @@ gtk_style_context_push_state (GtkStyleContext *context,
 {
   GtkStyleContextPrivate *priv = context->priv;
   GtkStateFlags current_state;
+  GtkCssNode *root;
 
   current_state = gtk_css_node_get_state (priv->cssnode);
 
   if (current_state == state)
     return state;
 
-  if (g_getenv ("GTK_STYLE_CONTEXT_WARNING"))
-    {
-      GtkCssNode *root = gtk_style_context_get_root (context);
+  root = gtk_style_context_get_root (context);
 
-      if (GTK_IS_CSS_WIDGET_NODE (root))
-        {
-          GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
-          g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()",
-                     state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode));
-        }
-      else
-        {
-          g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()",
-                     state, context, gtk_css_node_get_state (priv->cssnode));
-        }
+  if (GTK_IS_CSS_WIDGET_NODE (root))
+    {
+      GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
+      g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()",
+                 state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode));
+    }
+  else
+    {
+      g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()",
+                 state, context, gtk_css_node_get_state (priv->cssnode));
     }
 
   gtk_css_node_set_state (priv->cssnode, state);


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