summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2017-06-04 20:13:26 +0200
committerMatthias Clasen <mclasen@redhat.com>2017-07-19 21:27:13 -0400
commit99b00b4d9c9f02984c1cfca0319fcf148dbb0fed (patch)
tree959736007bf10841e0b451768f8e8ce0ef787ac4 /gtk
parentab1e8502e7997b1eb1012882f60dcf81e2ad85fb (diff)
downloadgtk+-99b00b4d9c9f02984c1cfca0319fcf148dbb0fed.tar.gz
sizerequest: Assert that min_size >= 0
This should generally be true, so remove the checks from gtkbox.c and move it into gtksizerequest.c
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkbox.c32
-rw-r--r--gtk/gtksizerequest.c11
2 files changed, 11 insertions, 32 deletions
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 312f535782..d71aa48b80 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 7505c8a4db..ea1b7c0663 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;