[gtk+] stylecontext: Don't do anything with empty widget path



commit 153a7e71ceaea8684ea6330faed70f743c3dde8c
Author: Benjamin Otte <otte redhat com>
Date:   Tue Jul 22 01:06:32 2014 +0200

    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 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index cc04eea..8146819 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++)


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