mirror of https://github.com/proxmox/mirror_qemu
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
parent
4fec640446
commit
52e636cdd8
|
@ -361,12 +361,14 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp)
|
||||||
|
|
||||||
void object_unparent(Object *obj)
|
void object_unparent(Object *obj)
|
||||||
{
|
{
|
||||||
|
object_ref(obj);
|
||||||
if (obj->parent) {
|
if (obj->parent) {
|
||||||
object_property_del_child(obj->parent, obj, NULL);
|
object_property_del_child(obj->parent, obj, NULL);
|
||||||
}
|
}
|
||||||
if (obj->class->unparent) {
|
if (obj->class->unparent) {
|
||||||
(obj->class->unparent)(obj);
|
(obj->class->unparent)(obj);
|
||||||
}
|
}
|
||||||
|
object_unref(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void object_deinit(Object *obj, TypeImpl *type)
|
static void object_deinit(Object *obj, TypeImpl *type)
|
||||||
|
|
Loading…
Reference in New Issue