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.
This commit is contained in:
Benjamin Otte 2015-11-06 18:57:24 +01:00
parent 68ed166c60
commit a9814fea7d

View File

@ -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);