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
This commit is contained in:
@@ -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 ||
|
||||
|
||||
Reference in New Issue
Block a user