clutter/tests/actor-destroy: Check destroying the actor clears the children

Commit df7d8e2cb highlights a crash on test_destroy_destroy, in fact it could
happen that calling clutter_actor_destroy on a child while iterating on the
list, would implicitly call test_destroy_remove that tries to modify the list
at the same time. Causing a memory error.

So instead of manually free the children list, just ensure that this list is
valid and that when the object destruction is done, this is free'd.

See: https://gitlab.gnome.org/GNOME/mutter/merge_requests/576

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
This commit is contained in:
Marco Trevisan (Treviño) 2019-05-15 18:31:26 -05:00
parent 0405786573
commit f99cd18254

View File

@ -114,11 +114,12 @@ test_destroy_destroy (ClutterActor *self)
test->tex = NULL;
}
g_list_free_full (test->children, (GDestroyNotify) clutter_actor_destroy);
test->children = NULL;
g_assert_nonnull (test->children);
if (CLUTTER_ACTOR_CLASS (test_destroy_parent_class)->destroy)
CLUTTER_ACTOR_CLASS (test_destroy_parent_class)->destroy (self);
g_assert_null (test->children);
}
static void