[gtk+/wip/baedert/widget-templates] widget: Fix checks in gtk_widget_snapshot()



commit 887659356d6771f139b6476a0b36223faf140e85
Author: Timm Bäder <mail baedert org>
Date:   Sun Mar 26 12:45:50 2017 +0200

    widget: Fix checks in gtk_widget_snapshot()
    
    If the widget isn't drawable anyway, just return;
    
    If the widget needs an allocate, print a warning, since it indiactes a
    problem in the widget workflow (e.g. forgot to size_allocate a child
    widget).
    
    This maches the previous checks in gtk_widget_draw (with the same
    problems).

 gtk/gtkwidget.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d418c36..c24606a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15439,9 +15439,15 @@ gtk_widget_snapshot (GtkWidget   *widget,
   double opacity;
   cairo_rectangle_int_t offset_clip;
 
-  if (_gtk_widget_get_alloc_needed (widget))
+  if (!_gtk_widget_is_drawable (widget))
     return;
 
+  if (_gtk_widget_get_alloc_needed (widget))
+    {
+      g_warning ("Trying to snapshot %s %p without a current allocation", G_OBJECT_TYPE_NAME (widget), 
widget);
+      return;
+    }
+
   priv = widget->priv;
   offset_clip = priv->clip;
   offset_clip.x -= priv->allocation.x;


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