From a3a2fbfd5a738ffeb2b8f55183ff49dc8e884342 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 7 Jun 2012 11:34:12 +0100 Subject: [PATCH] actor: Improve the debug name Only for debug builds, the debug name should include a) actor name, b) type name, and c) pointer address. For non-debug builds we can live with the actor/type name. --- clutter/clutter-actor.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 4a5d8b917..8f87730a6 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -754,6 +754,11 @@ struct _ClutterActorPrivate ClutterColor bg_color; +#ifdef CLUTTER_ENABLE_DEBUG + /* a string used for debugging messages */ + gchar *debug_name; +#endif + /* bitfields */ /* fixed position and sizes */ @@ -1051,8 +1056,27 @@ G_DEFINE_TYPE_WITH_CODE (ClutterActor, const gchar * _clutter_actor_get_debug_name (ClutterActor *actor) { - return actor->priv->name != NULL ? actor->priv->name - : G_OBJECT_TYPE_NAME (actor); + ClutterActorPrivate *priv = actor->priv; + const gchar *retval; + +#ifdef CLUTTER_ENABLE_DEBUG + if (G_UNLIKELY (priv->debug_name == NULL)) + { + priv->debug_name = g_strdup_printf ("<%s>[<%s>:%p]", + priv->name != NULL ? priv->name + : "unnamed", + G_OBJECT_TYPE_NAME (actor), + actor); + } + + retval = priv->debug_name; +#else + retval = priv->name != NULL + ? priv->name + : G_OBJECT_TYPE_NAME (actor); +#endif + + return retval; } #ifdef CLUTTER_ENABLE_DEBUG @@ -5274,6 +5298,10 @@ clutter_actor_finalize (GObject *object) g_free (priv->name); +#ifdef CLUTTER_ENABLE_DEBUG + g_free (priv->debug_name); +#endif + G_OBJECT_CLASS (clutter_actor_parent_class)->finalize (object); }