script: Fix the memory management
Currently, the memory management in ClutterScript is overly complicated. The basic design tenet should be: - ClutterScript owns a reference on every object it creates This allows the Script instance to reliably handle the lifetime of the instances from creation to disposal. In case of unmerge, the Script instance should destroy any Actor instance, except for the Stage, and release the reference it owns. The Stage is special because it's really owned by Clutter itself, and it should be destroyed explicitly. When disposing the Script itself, it should just release the reference; any parented actor, or any InitiallyUnowned instance, will then be managed by the parent object, as they should, while every GObject instance will go away, as documented. This commit is based on a patch by: Henrik Hedberg <hhedberg@innologies.fi> http://bugzilla.clutter-project.org/show_bug.cgi?id=2316
This commit is contained in:
@ -314,26 +314,16 @@ object_info_free (gpointer data)
|
||||
* unless we are unmerging in which case we have to destroy
|
||||
* the actor to unparent them
|
||||
*/
|
||||
if (oinfo->object)
|
||||
if (oinfo->object != NULL)
|
||||
{
|
||||
if (oinfo->is_unmerged)
|
||||
{
|
||||
if (oinfo->is_toplevel)
|
||||
g_object_unref (oinfo->object);
|
||||
else
|
||||
{
|
||||
/* destroy every actor, unless it's the default stage */
|
||||
if (oinfo->is_stage_default == FALSE &&
|
||||
CLUTTER_IS_ACTOR (oinfo->object))
|
||||
clutter_actor_destroy (CLUTTER_ACTOR (oinfo->object));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oinfo->is_toplevel)
|
||||
g_object_unref (oinfo->object);
|
||||
if (oinfo->is_actor && !oinfo->is_stage)
|
||||
clutter_actor_destroy (CLUTTER_ACTOR (oinfo->object));
|
||||
}
|
||||
|
||||
g_object_unref (oinfo->object);
|
||||
|
||||
oinfo->object = NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user