From 376bf4a99084138b4728a80ac17fa0c0001892a9 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 8 Dec 2011 10:01:53 +0000 Subject: [PATCH] actor: Tweak the underallocation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are only two kinds of actors that allow underallocations, according to the API contract: • ClutterStage, as it is a viewport and it doesn't have an implicit minimum size; • Actors using the CLUTTER_ACTOR_NO_LAYOUT escape hatch, which allows them to bail out from our layout management policies. The warning about underallocations should take these two exceptions under consideration. --- clutter/clutter-actor.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index ea4dc040a..bf4a2a893 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -1262,7 +1262,7 @@ clutter_actor_real_show (ClutterActor *self) /* we queue a relayout unless the actor is inside a * container that explicitly told us not to */ - if (priv->parent_actor && + if (priv->parent_actor != NULL && (!(priv->parent_actor->flags & CLUTTER_ACTOR_NO_LAYOUT))) { /* While an actor is hidden the parent may not have @@ -1384,7 +1384,7 @@ clutter_actor_real_hide (ClutterActor *self) /* we queue a relayout unless the actor is inside a * container that explicitly told us not to */ - if (priv->parent_actor && + if (priv->parent_actor != NULL && (!(priv->parent_actor->flags & CLUTTER_ACTOR_NO_LAYOUT))) clutter_actor_queue_relayout (priv->parent_actor); } @@ -6999,14 +6999,22 @@ clutter_actor_adjust_allocation (ClutterActor *self, { 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, - parent != NULL ? _clutter_actor_get_debug_name (parent) - : "top-level", - min_width, min_height); + /* the only actors that are allowed to be underallocated are the Stage, + * as it doesn't have an implicit size, and Actors that specifically + * told us that they want to opt-out from layout control mechanisms + * through the NO_LAYOUT escape hatch. + */ + if (parent != NULL && + !(self->flags & CLUTTER_ACTOR_NO_LAYOUT) != 0) + { + 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 (parent), + min_width, min_height); + } } #endif