From 52e636cdd8528b8f72f43b653356ac177524912b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 25 Jan 2013 14:12:30 +0100 Subject: qom: preserve object while unparenting it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Paolo Bonzini Signed-off-by: Anthony Liguori --- qom/object.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qom/object.c') diff --git a/qom/object.c b/qom/object.c index e200282172..034f15cdec 100644 --- a/qom/object.c +++ b/qom/object.c @@ -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) -- cgit v1.2.3