Commit bffc687d authored by Paolo Bonzini's avatar Paolo Bonzini

qom: object: move unparenting to the child property's release callback

This ensures that the unparent callback is called automatically
when the parent object is finalized.

Note that there's no need to keep a reference neither in
object_unparent nor in object_finalize_child_property.  The
reference held by the child property itself will do.
Reviewed-by: default avatarPeter Crosthwaite <>
Signed-off-by: default avatarPaolo Bonzini <>
parent 76a6e1cc
......@@ -387,19 +387,9 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp)
void object_unparent(Object *obj)
if (!obj->parent) {
if (obj->class->unparent) {
if (obj->parent) {
object_property_del_child(obj->parent, obj, NULL);
obj->parent = NULL;
static void object_deinit(Object *obj, TypeImpl *type)
......@@ -1042,6 +1032,10 @@ static void object_finalize_child_property(Object *obj, const char *name,
Object *child = opaque;
if (child->class->unparent) {
child->parent = NULL;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment