From b4d3b52b625717ee66c7e01d810559ac6ac8f8ef Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 24 Nov 2011 14:11:00 +0000 Subject: [PATCH] actor: Update the underallocations check Add a failsafe against a NULL parent, to avoid a segfault when calling clutter_actor_allocate() on the Stage. We also need to deal with floating point values: straight comparison is not going to cut it. --- clutter/clutter-actor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index cb7902e7a..9048b10dd 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -6610,14 +6610,18 @@ clutter_actor_adjust_allocation (ClutterActor *self, #ifdef CLUTTER_ENABLE_DEBUG /* warn about underallocations */ - if ((min_width > alloc_width) || (min_height > alloc_height)) + if (floorf (min_width - alloc_width) > 0 || + floorf (min_height - alloc_height) > 0) { + ClutterActor *parent = clutter_actor_get_parent (self); + g_warning (G_STRLOC ": The actor '%s' is getting an allocation " "of %.2f x %.2f from its parent actor '%s', but its " "requested minimum size is of %.2f x %.2f", _clutter_actor_get_debug_name (self), alloc_width, alloc_height, - _clutter_actor_get_debug_name (priv->parent_actor), + parent != NULL ? _clutter_actor_get_debug_name (parent) + : "top-level", min_width, min_height); } #endif