actor: Show actor name or type in the state checks warnings

When showing a warning in the state checks we perform to verify that
the invariants are maintained when showing, mapping and realizing, we
should also print out the name of the actor failing the checks. If the
actor has no name, the GType name should be used as a fallback.
This commit is contained in:
Emmanuele Bassi 2009-10-23 09:48:35 +01:00
parent f028744706
commit 7de47e74bd

View File

@ -533,14 +533,19 @@ clutter_actor_verify_map_state (ClutterActor *self)
{ {
} }
else else
g_warning ("Realized non-toplevel actor should have a parent"); g_warning ("Realized non-toplevel actor '%s' should "
"have a parent",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
} }
else if (!CLUTTER_ACTOR_IS_REALIZED (priv->parent_actor)) else if (!CLUTTER_ACTOR_IS_REALIZED (priv->parent_actor))
{ {
g_warning ("Realized actor %s[%p] has an unrealized parent %s[%p]", g_warning ("Realized actor %s has an unrealized parent %s",
G_OBJECT_TYPE_NAME (self), self, priv->name ? priv->name
G_OBJECT_TYPE_NAME (priv->parent_actor), : G_OBJECT_TYPE_NAME (self),
priv->parent_actor); clutter_actor_get_name (priv->parent_actor)
? clutter_actor_get_name (priv->parent_actor)
: G_OBJECT_TYPE_NAME (priv->parent_actor));
} }
} }
} }
@ -548,7 +553,9 @@ clutter_actor_verify_map_state (ClutterActor *self)
if (CLUTTER_ACTOR_IS_MAPPED (self)) if (CLUTTER_ACTOR_IS_MAPPED (self))
{ {
if (!CLUTTER_ACTOR_IS_REALIZED (self)) if (!CLUTTER_ACTOR_IS_REALIZED (self))
g_warning ("Actor is mapped but not realized"); g_warning ("Actor '%s' is mapped but not realized",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
/* remaining bets are off during reparent when we're potentially /* remaining bets are off during reparent when we're potentially
* mapped, but should not be according to invariants * mapped, but should not be according to invariants
@ -562,13 +569,17 @@ clutter_actor_verify_map_state (ClutterActor *self)
if (!CLUTTER_ACTOR_IS_VISIBLE (self) && if (!CLUTTER_ACTOR_IS_VISIBLE (self) &&
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION)) !(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION))
{ {
g_warning ("Toplevel actor is mapped but not visible"); g_warning ("Toplevel actor '%s' is mapped "
"but not visible",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
} }
} }
else else
{ {
g_warning ("Mapped actor %s %p should have a parent", g_warning ("Mapped actor '%s' should have a parent",
G_OBJECT_TYPE_NAME (self), self); priv->name ? priv->name
:G_OBJECT_TYPE_NAME (self));
} }
} }
else else
@ -590,22 +601,28 @@ clutter_actor_verify_map_state (ClutterActor *self)
if (!CLUTTER_ACTOR_IS_VISIBLE (priv->parent_actor)) if (!CLUTTER_ACTOR_IS_VISIBLE (priv->parent_actor))
{ {
g_warning ("Actor should not be mapped if parent " g_warning ("Actor '%s' should not be mapped if parent "
"is not visible"); "is not visible",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
} }
if (!CLUTTER_ACTOR_IS_REALIZED (priv->parent_actor)) if (!CLUTTER_ACTOR_IS_REALIZED (priv->parent_actor))
{ {
g_warning ("Actor should not be mapped if parent " g_warning ("Actor '%s' should not be mapped if parent "
"is not realized"); "is not realized",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
} }
if (!(CLUTTER_PRIVATE_FLAGS (priv->parent_actor) & if (!(CLUTTER_PRIVATE_FLAGS (priv->parent_actor) &
CLUTTER_ACTOR_IS_TOPLEVEL)) CLUTTER_ACTOR_IS_TOPLEVEL))
{ {
if (!CLUTTER_ACTOR_IS_MAPPED (priv->parent_actor)) if (!CLUTTER_ACTOR_IS_MAPPED (priv->parent_actor))
g_warning ("Actor is mapped but its non-toplevel " g_warning ("Actor '%s' is mapped but its non-toplevel "
"parent is not mapped"); "parent is not mapped",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
} }
} }
} }
@ -776,7 +793,9 @@ clutter_actor_update_map_state (ClutterActor *self,
if (priv->enable_paint_unmapped) if (priv->enable_paint_unmapped)
{ {
if (priv->parent_actor == NULL) if (priv->parent_actor == NULL)
g_warning ("Attempting to map an unparented actor"); g_warning ("Attempting to map an unparented actor '%s'",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
should_be_mapped = TRUE; should_be_mapped = TRUE;
must_be_realized = TRUE; must_be_realized = TRUE;
@ -790,12 +809,16 @@ clutter_actor_update_map_state (ClutterActor *self,
{ {
if (parent == NULL) if (parent == NULL)
g_warning ("Attempting to map a child that does not " g_warning ("Attempting to map a child that does not "
"meet the necessary invariants: the actor " "meet the necessary invariants: the actor '%s' "
"has no parent"); "has no parent",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
else else
g_warning ("Attempting to map a child that does not " g_warning ("Attempting to map a child that does not "
"meet the necessary invariants: the actor " "meet the necessary invariants: the actor '%s' "
"is parented to an unmapped actor"); "is parented to an unmapped actor",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
} }
/* If in reparent, we temporarily suspend unmap and unrealize. /* If in reparent, we temporarily suspend unmap and unrealize.
@ -826,8 +849,10 @@ clutter_actor_update_map_state (ClutterActor *self,
if (should_be_mapped) if (should_be_mapped)
{ {
if (!must_be_realized) if (!must_be_realized)
g_warning ("Somehow we think an actor should be mapped but " g_warning ("Somehow we think actor '%s' should be mapped but "
"not realized, which isn't allowed"); "not realized, which isn't allowed",
priv->name ? priv->name
: G_OBJECT_TYPE_NAME (self));
/* realization is allowed to fail (though I don't know what /* realization is allowed to fail (though I don't know what
* an app is supposed to do about that - shouldn't it just * an app is supposed to do about that - shouldn't it just