[gtk+] gadget: Warn about missing size allocation



commit dde33623ca3a26ab1c480d918bd86b7f2a24d0f2
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Feb 24 22:18:13 2016 -0500

    gadget: Warn about missing size allocation
    
    When size_allocate is overridden in widgets, but draw is not,
    we can end up drawing a gadget that has not been given a size.
    
    Warn about this, and limp along by drawing the gadget over the
    full allocation of its owner widget.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762614

 gtk/gtkcssgadget.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssgadget.c b/gtk/gtkcssgadget.c
index 5bb7cac..b907839 100644
--- a/gtk/gtkcssgadget.c
+++ b/gtk/gtkcssgadget.c
@@ -284,7 +284,11 @@ gtk_css_gadget_class_init (GtkCssGadgetClass *klass)
 static void
 gtk_css_gadget_init (GtkCssGadget *gadget)
 {
+  GtkCssGadgetPrivate *priv = gtk_css_gadget_get_instance_private (gadget);
 
+  priv->allocated_size.width = -1;
+  priv->allocated_size.height = -1;
+  priv->allocated_baseline = -1;
 }
 
 /**
@@ -729,6 +733,16 @@ gtk_css_gadget_draw (GtkCssGadget *gadget,
   width = priv->allocated_size.width;
   height = priv->allocated_size.height;
 
+  if (width < 0 || height < 0)
+    {
+      g_warning ("Drawing a gadget with negative dimensions. "
+                 "Did you forget to allocate a size?");
+      x = 0;
+      y = 0;
+      width = gtk_widget_get_allocated_width (priv->owner);
+      height = gtk_widget_get_allocated_height (priv->owner);
+    }
+
   style = gtk_css_gadget_get_style (gadget);
   get_box_margin (style, &margin);
   get_box_border (style, &border);


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