qom: preserve object while unparenting it

Avoid that the object disappears after it's deleted from the QOM
composition tree, in case that was the only reference to it.

Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
master
Paolo Bonzini 2013-01-25 14:12:30 +01:00 committed by Anthony Liguori
parent 4fec640446
commit 52e636cdd8
1 changed files with 2 additions and 0 deletions

View File

@ -361,12 +361,14 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp)
void object_unparent(Object *obj)
{
object_ref(obj);
if (obj->parent) {
object_property_del_child(obj->parent, obj, NULL);
}
if (obj->class->unparent) {
(obj->class->unparent)(obj);
}
object_unref(obj);
}
static void object_deinit(Object *obj, TypeImpl *type)