[gtk+] widget: Warn when allocation for gtk_widget_size_allocate() is too small
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget: Warn when allocation for gtk_widget_size_allocate() is too small
- Date: Thu, 28 Apr 2011 03:13:41 +0000 (UTC)
commit 92f9892ccabd2a1b05f7ea2382abbf8d441ec14f
Author: Benjamin Otte <otte redhat com>
Date: Thu Apr 28 05:12:00 2011 +0200
widget: Warn when allocation for gtk_widget_size_allocate() is too small
Widgets may not be underallocated, it is the responsibility of the
caller to ensure this never happens.
gtk/gtkwidget.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 0731202..f45d490 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4804,7 +4804,7 @@ gtk_widget_size_allocate (GtkWidget *widget,
* when aligning implicitly.
*/
gtk_widget_get_preferred_width (widget, &min_width, &natural_width);
- gtk_widget_get_preferred_height_for_width (widget, real_allocation.width, &dummy, &natural_height);
+ gtk_widget_get_preferred_height_for_width (widget, real_allocation.width, &min_height, &natural_height);
}
else
{
@@ -4813,9 +4813,15 @@ gtk_widget_size_allocate (GtkWidget *widget,
* when aligning implicitly.
*/
gtk_widget_get_preferred_height (widget, &min_height, &natural_height);
- gtk_widget_get_preferred_width_for_height (widget, real_allocation.height, &dummy, &natural_width);
+ gtk_widget_get_preferred_width_for_height (widget, real_allocation.height, &min_width, &natural_width);
}
+ if (min_width > real_allocation.width || min_height > real_allocation.height)
+ g_warning ("gtk_widget_size_allocate(): attempt to underallocate %s %p. "
+ "Allocation is %dx%d, but minimum required size is %dx%d.",
+ G_OBJECT_TYPE_NAME (widget), widget,
+ real_allocation.width, real_allocation.height,
+ min_width, min_height);
/* Now that we have the right natural height and width, go ahead and remove any margins from the
* allocated sizes and possibly limit them to the natural sizes */
GTK_WIDGET_GET_CLASS (widget)->adjust_size_allocation (widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]