From 153a7e71ceaea8684ea6330faed70f743c3dde8c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 22 Jul 2014 01:06:32 +0200 Subject: [PATCH] stylecontext: Don't do anything with empty widget path It's a corner case, but empty widget paths don't allow setting state/regions/classes, so exit early Fixes gtk/stylecontext test. --- gtk/gtkstylecontext.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cc04eea70f..8146819ba0 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -718,11 +718,14 @@ create_query_path (GtkStyleContext *context, { GtkStyleContextPrivate *priv; GtkWidgetPath *path; - guint i, pos; + guint i, pos, length; priv = context->priv; path = priv->widget ? _gtk_widget_create_path (priv->widget) : gtk_widget_path_copy (priv->widget_path); - pos = gtk_widget_path_length (path) - 1; + length = gtk_widget_path_length (path); + if (length == 0) + return path; + pos = length - 1; /* Set widget regions */ for (i = 0; i < info->regions->len; i++)