diff options
| author | Paolo Bonzini | 2012-08-22 23:09:46 +0200 |
|---|---|---|
| committer | Anthony Liguori | 2012-08-24 03:19:59 +0200 |
| commit | da5a44e8b0b727681fc33e8d94832d1cae48a788 (patch) | |
| tree | 05d07ea897538eed23cc86e097d43863f577bfeb /qom | |
| parent | monitor: don't try to initialize json parser when monitor is HMP (diff) | |
| download | qemu-da5a44e8b0b727681fc33e8d94832d1cae48a788.tar.gz qemu-da5a44e8b0b727681fc33e8d94832d1cae48a788.tar.xz qemu-da5a44e8b0b727681fc33e8d94832d1cae48a788.zip | |
qom: object_delete should unparent the object first
object_deinit is only called when the reference count goes to zero,
and yet tries to do an object_unparent. Now, object_unparent
either does nothing or it will decrease the reference count.
Because we know the reference count is zero, the object_unparent
call in object_deinit is useless.
Instead, we need to disconnect the object from its parent just
before we remove the last reference apart from the parent's. This
happens in object_delete. Once we do this, all calls to
object_unparent peppered through QEMU can go away.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qom')
| -rw-r--r-- | qom/object.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/qom/object.c b/qom/object.c index a552be258e..e3e9242638 100644 --- a/qom/object.c +++ b/qom/object.c @@ -373,8 +373,6 @@ static void object_deinit(Object *obj, TypeImpl *type) if (type_has_parent(type)) { object_deinit(obj, type_get_parent(type)); } - - object_unparent(obj); } void object_finalize(void *data) @@ -411,8 +409,9 @@ Object *object_new(const char *typename) void object_delete(Object *obj) { + object_unparent(obj); + g_assert(obj->ref == 1); object_unref(obj); - g_assert(obj->ref == 0); g_free(obj); } |
