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.
This commit is contained in:
parent
d2c091e62d
commit
ede2cbfab0
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user