From ede2cbfab05035247b2a6a2ca837cb8f71871c5d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 3 Dec 2009 21:07:45 +0000 Subject: [PATCH] stage: Create the default stage on demand Instead of creating the default stage during initialization we can now safely create it whenever clutter_stage_get_default() is called. To maintain the invariant, the default stage is immediately realized by Clutter itself. --- clutter/clutter-main.c | 28 ---------------------------- clutter/clutter-stage.c | 15 ++++++++++----- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 3a74a07..6347031 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -1492,7 +1492,6 @@ static ClutterInitError clutter_init_real (GError **error) { ClutterMainContext *ctx; - ClutterActor *stage; ClutterBackend *backend; /* Note, creates backend if not already existing, though parse args will @@ -1558,33 +1557,6 @@ clutter_init_real (GError **error) /* Initiate event collection */ _clutter_backend_init_events (ctx->backend); - /* Create the default stage and realize it */ - stage = clutter_stage_get_default (); - if (!stage) - { - if (error) - g_set_error (error, CLUTTER_INIT_ERROR, - CLUTTER_INIT_ERROR_INTERNAL, - "Unable to create the default stage"); - else - g_critical ("Unable to create the default stage"); - - return CLUTTER_INIT_ERROR_INTERNAL; - } - - clutter_actor_realize (stage); - if (!CLUTTER_ACTOR_IS_REALIZED (stage)) - { - if (error) - g_set_error (error, CLUTTER_INIT_ERROR, - CLUTTER_INIT_ERROR_INTERNAL, - "Unable to realize the default stage"); - else - g_critical ("Unable to realize the default stage"); - - return CLUTTER_INIT_ERROR_INTERNAL; - } - clutter_is_initialized = TRUE; ctx->is_initialized = TRUE; diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index b164e50..c67056d 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -1215,11 +1215,16 @@ clutter_stage_get_default (void) stage = clutter_stage_manager_get_default_stage (stage_manager); if (G_UNLIKELY (stage == NULL)) - /* This will take care of automatically adding the stage to the - * stage manager and setting it as the default. Its floating - * reference will be claimed by the stage manager. - */ - stage = g_object_new (CLUTTER_TYPE_STAGE, NULL); + { + /* This will take care of automatically adding the stage to the + * stage manager and setting it as the default. Its floating + * reference will be claimed by the stage manager. + */ + stage = g_object_new (CLUTTER_TYPE_STAGE, NULL); + + /* the default stage is realized by default */ + clutter_actor_realize (CLUTTER_ACTOR (stage)); + } return CLUTTER_ACTOR (stage); } -- 2.7.4