diff options
author | Benjamin Otte <otte@redhat.com> | 2021-11-19 21:58:09 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2021-11-19 23:46:59 +0100 |
commit | 163616cc0ada31ad667e8db7b22a6fa817021ebc (patch) | |
tree | ad3e46bf64c5bfc41753dc6d00649f6984a38905 /gtk/gtksizerequest.c | |
parent | e378dc4c2842f4b35189ad7d1ca6cc77f80f0461 (diff) | |
download | gtk+-163616cc0ada31ad667e8db7b22a6fa817021ebc.tar.gz |
sizerequest: Add a critical when for_size is too small
It's not expensive to check it because we'll cache the dfault size
request anyway, and people do it wrong a lot.
As a bonus, don't do any return_if_fail(), just use the min size
instead.
Diffstat (limited to 'gtk/gtksizerequest.c')
-rw-r--r-- | gtk/gtksizerequest.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index a0f066b997..199bce2575 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -488,6 +488,18 @@ gtk_widget_measure (GtkWidget *widget, g_return_if_fail (orientation == GTK_ORIENTATION_HORIZONTAL || orientation == GTK_ORIENTATION_VERTICAL); + if (for_size >= 0) + { + int min_opposite_size; + gtk_widget_measure (widget, OPPOSITE_ORIENTATION (orientation), -1, &min_opposite_size, NULL, NULL, NULL); + if (for_size < min_opposite_size) + { + g_critical ("gtk_widget_measure: assertion 'for_size >= minimum opposite size' failed for %s %p: %u >= %u", + G_OBJECT_TYPE_NAME (widget), widget, for_size, min_opposite_size); + for_size = min_opposite_size; + } + } + /* This is the main function that checks for a cached size and * possibly queries the widget class to compute the size if it's * not cached. |