From 53ae5a1c09fb4fc8e8c81e6ebdd5cbb93bc39c3d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 2 Apr 2011 03:57:27 +0200 Subject: [PATCH] widget: Do the sanity checks earlier This avoids a crash in broken applications, in particular the gdm greeter. https://bugzilla.gnome.org/show_bug.cgi?id=646498 --- gtk/gtkwidget.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3f996469c8..4c18fc17c5 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4796,6 +4796,16 @@ gtk_widget_size_allocate (GtkWidget *widget, old_allocation = priv->allocation; real_allocation = *allocation; + if (real_allocation.width < 0 || real_allocation.height < 0) + { + g_warning ("gtk_widget_size_allocate(): attempt to allocate widget with width %d and height %d", + real_allocation.width, + real_allocation.height); + } + + real_allocation.width = MAX (real_allocation.width, 1); + real_allocation.height = MAX (real_allocation.height, 1); + adjusted_allocation = real_allocation; if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH) { @@ -4849,16 +4859,6 @@ gtk_widget_size_allocate (GtkWidget *widget, real_allocation = adjusted_allocation; } - if (real_allocation.width < 0 || real_allocation.height < 0) - { - g_warning ("gtk_widget_size_allocate(): attempt to allocate widget with width %d and height %d", - real_allocation.width, - real_allocation.height); - } - - real_allocation.width = MAX (real_allocation.width, 1); - real_allocation.height = MAX (real_allocation.height, 1); - size_changed = (old_allocation.width != real_allocation.width || old_allocation.height != real_allocation.height); position_changed = (old_allocation.x != real_allocation.x ||