From bb8abe832ec11cdc9c336cc949ce913ef4e131e7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 17 Jan 2012 18:13:42 +0000 Subject: [PATCH] actor: Do not use ::constructed If we want to set a default layout manager, we need to do so inside init(), as it's not guaranteed that people subclassing Actor and overriding ::constructed will actually chain up as they should. --- clutter/clutter-actor.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index c51d8c049..c313d3f6a 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -674,6 +674,9 @@ static void _clutter_actor_get_relative_transformation_matrix (ClutterActor *sel static ClutterPaintVolume *_clutter_actor_get_paint_volume_mutable (ClutterActor *self); +static void on_layout_manager_changed (ClutterLayoutManager *manager, + ClutterActor *self); + /* Helper macro which translates by the anchor coord, applies the given transformation and then translates back */ #define TRANSFORM_ABOUT_ANCHOR_COORD(a,m,c,_transform) G_STMT_START { \ @@ -4419,21 +4422,6 @@ clutter_actor_real_has_overlaps (ClutterActor *self) return TRUE; } -static void -clutter_actor_constructed (GObject *gobject) -{ - ClutterActor *self = CLUTTER_ACTOR (gobject); - - /* if we weren't constructed with a layout manager, we fall back to a - * fixed layout; this is the most sensible option, as it will make - * things like constraints work out of the box - */ - if (self->priv->layout_manager == NULL) - clutter_actor_set_layout_manager (self, clutter_fixed_layout_new ()); - - G_OBJECT_CLASS (clutter_actor_parent_class)->constructed (gobject); -} - static void clutter_actor_class_init (ClutterActorClass *klass) { @@ -4443,7 +4431,6 @@ clutter_actor_class_init (ClutterActorClass *klass) quark_actor_layout_info = g_quark_from_static_string ("-clutter-actor-layout-info"); quark_actor_transform_info = g_quark_from_static_string ("-clutter-actor-transform-info"); - object_class->constructed = clutter_actor_constructed; object_class->set_property = clutter_actor_set_property; object_class->get_property = clutter_actor_get_property; object_class->dispose = clutter_actor_dispose; @@ -5996,6 +5983,18 @@ clutter_actor_init (ClutterActor *self) priv->last_paint_volume_valid = TRUE; priv->transform_valid = FALSE; + + /* we need to create the default layout manager here, because + * constructed() may not end up being called, if for instance + * somebody forgot to chain up + */ + priv->layout_manager = clutter_fixed_layout_new (); + g_object_ref_sink (priv->layout_manager); + clutter_layout_manager_set_container (priv->layout_manager, + CLUTTER_CONTAINER (self)); + g_signal_connect (priv->layout_manager, "layout-changed", + G_CALLBACK (on_layout_manager_changed), + self); } /**