From dde33623ca3a26ab1c480d918bd86b7f2a24d0f2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 Feb 2016 22:18:13 -0500 Subject: [PATCH] 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 file changed, 14 insertions(+) diff --git a/gtk/gtkcssgadget.c b/gtk/gtkcssgadget.c index 5bb7cac151..b907839dc2 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);