[gtk+] widget: Clarify some corner cases



commit 7ecdaaacb2d8a4454ef44517adb296b31746d99f
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 29 01:55:06 2014 +0100

    widget: Clarify some corner cases
    
    I checked Cairo source code (actually pixman, as Cairo just passes
    through) to make sure that the behavior stays identical: negative values
    cause an error message from pixman, zero is allowed. Both return an
    empty region which gtk_widget_queue_draw_region() would then proceed to
    ignore.

 gtk/gtkwidget.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 7ff1aff..0be0272 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5657,6 +5657,9 @@ gtk_widget_queue_draw_region (GtkWidget            *widget,
  * defined as @widget->window coordinates for widgets that are not
  * #GTK_NO_WINDOW widgets, and are relative to @widget->allocation.x,
  * @widget->allocation.y for widgets that are #GTK_NO_WINDOW widgets.
+ *
+ * @width or @height may be 0, in this case this function does
+ * nothing. Negative values for @width and @height are not allowed.
  */
 void
 gtk_widget_queue_draw_area (GtkWidget *widget,
@@ -5669,6 +5672,11 @@ gtk_widget_queue_draw_area (GtkWidget *widget,
   cairo_region_t *region;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (width >= 0);
+  g_return_if_fail (height >= 0);
+
+  if (width == 0 || height == 0)
+    return;
 
   rect.x = x;
   rect.y = y;


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