[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/9] qom: object: move unparenting to the child prop
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 2/9] qom: object: move unparenting to the child property's release callback |
Date: |
Wed, 30 Jul 2014 12:27:05 +0200 |
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: Peter Crosthwaite <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qom/object.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index f301bc2..1b00831 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -387,19 +387,9 @@ static void object_property_del_child(Object *obj, Object
*child, Error **errp)
void object_unparent(Object *obj)
{
- if (!obj->parent) {
- return;
- }
-
- object_ref(obj);
- if (obj->class->unparent) {
- (obj->class->unparent)(obj);
- }
if (obj->parent) {
object_property_del_child(obj->parent, obj, NULL);
- obj->parent = NULL;
}
- object_unref(obj);
}
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->class->unparent)(child);
+ }
+ child->parent = NULL;
object_unref(child);
}
--
1.8.3.1
- [Qemu-devel] [PATCH for-2.2 0/9] memory: remove memory_region_destroy, Paolo Bonzini, 2014/07/30
- [Qemu-devel] [PATCH 1/9] qom: object: delete properties before calling instance_finalize, Paolo Bonzini, 2014/07/30
- [Qemu-devel] [PATCH 4/9] vga: do not dynamically allocate chain4_alias, Paolo Bonzini, 2014/07/30
- [Qemu-devel] [PATCH 2/9] qom: object: move unparenting to the child property's release callback,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 3/9] sysbus: remove unused function sysbus_del_io, Paolo Bonzini, 2014/07/30
- [Qemu-devel] [PATCH 5/9] nic: do not destroy memory regions in cleanup functions, Paolo Bonzini, 2014/07/30
- [Qemu-devel] [PATCH 6/9] ioport: split deletion and destruction, Paolo Bonzini, 2014/07/30
- [Qemu-devel] [PATCH 7/9] memory: convert memory_region_destroy to object_unparent, Paolo Bonzini, 2014/07/30
- [Qemu-devel] [PATCH 8/9] memory: remove memory_region_destroy, Paolo Bonzini, 2014/07/30