From 8cb03a8cc079c490029b3ef9c99382a584dde298 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 9 Sep 2020 17:07:01 +0200 Subject: [PATCH] widget: Add a critical when allocation is too small. --- gtk/gtkwidget.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 18038fd1a4..01ea24da59 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3785,6 +3785,28 @@ gtk_widget_allocate (GtkWidget *widget, "How does the code know the size to allocate?", gtk_widget_get_name (widget), widget); } + if (!GTK_IS_SCROLLABLE (widget)) + { + int min; + gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, width, &min, NULL, NULL, NULL); + if (min > height) + { + g_critical ("Allocation height too small. Tried to allocate %dx%d, but %s %p needs " + "at least %dx%d.", + width, height, + gtk_widget_get_name (widget), widget, + width, min); + } + gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL); + if (min > width) + { + g_critical ("Allocation width too small. Tried to allocate %dx%d, but %s %p needs " + "at least %dx%d.", + width, height, + gtk_widget_get_name (widget), widget, + min, height); + } + } #endif /* G_ENABLE_DEBUG */ alloc_needed = priv->alloc_needed;