[gtk+/wip/baedert/drawing: 56/66] sizerequest: Assert that min_size >= 0
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing: 56/66] sizerequest: Assert that min_size >= 0
- Date: Thu, 15 Jun 2017 19:57:39 +0000 (UTC)
commit effc5b72fcbe0c36cbd2150c3d19db5181b87409
Author: Timm Bäder <mail baedert org>
Date: Sun Jun 4 20:13:26 2017 +0200
sizerequest: Assert that min_size >= 0
This should generally be true, so remove the checks from gtkbox.c and
move it into gtksizerequest.c
gtk/gtkbox.c | 32 --------------------------------
gtk/gtksizerequest.c | 11 +++++++++++
2 files changed, 11 insertions(+), 32 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 312f535..d71aa48 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -433,24 +433,6 @@ gtk_box_size_allocate_no_center (GtkWidget *widget,
&sizes[i].minimum_size, &sizes[i].natural_size,
NULL, NULL);
- /* Assert the api is working properly */
- if (sizes[i].minimum_size < 0)
- g_error ("GtkBox child %s minimum %s: %d < 0 for %s %d",
- gtk_widget_get_name (GTK_WIDGET (child->widget)),
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
- sizes[i].minimum_size,
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "height" : "width",
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? allocation->height :
allocation->width);
-
- if (sizes[i].natural_size < sizes[i].minimum_size)
- g_error ("GtkBox child %s natural %s: %d < minimum %d for %s %d",
- gtk_widget_get_name (GTK_WIDGET (child->widget)),
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
- sizes[i].natural_size,
- sizes[i].minimum_size,
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "height" : "width",
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? allocation->height :
allocation->width);
-
children_minimum_size += sizes[i].minimum_size;
sizes[i].data = child;
@@ -1117,20 +1099,6 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
&sizes[i].minimum_size, &sizes[i].natural_size,
NULL, NULL);
- /* Assert the api is working properly */
- if (sizes[i].minimum_size < 0)
- g_error ("GtkBox child %s minimum %s: %d < 0",
- gtk_widget_get_name (GTK_WIDGET (child->widget)),
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
- sizes[i].minimum_size);
-
- if (sizes[i].natural_size < sizes[i].minimum_size)
- g_error ("GtkBox child %s natural %s: %d < minimum %d",
- gtk_widget_get_name (GTK_WIDGET (child->widget)),
- (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
- sizes[i].natural_size,
- sizes[i].minimum_size);
-
children_minimum_size += sizes[i].minimum_size;
sizes[i].data = child;
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 7505c8a..ea1b7c0 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -238,6 +238,17 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
G_OBJECT_TYPE_NAME (widget), widget, min_size, nat_size, for_size);
}
+
+ nat_size = min_size;
+ }
+ else if (G_UNLIKELY (min_size < 0))
+ {
+ g_warning ("%s %p reported min %s %d, but sizes must be >= 0",
+ G_OBJECT_TYPE_NAME (widget), widget,
+ orientation == GTK_ORIENTATION_HORIZONTAL ? "width" : "height",
+ min_size);
+ min_size = 0;
+ nat_size = MAX (0, min_size);
}
adjusted_min = min_size;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]