qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 03/11] qom: preserve object while unparenting it


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 03/11] qom: preserve object while unparenting it
Date: Wed, 5 Dec 2012 21:44:34 +0100

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

Signed-off-by: Paolo Bonzini <address@hidden>
---
 qom/object.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qom/object.c b/qom/object.c
index 0739aa2..ecdf164 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -360,12 +360,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)
-- 
1.8.0.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]