summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qom/object.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/qom/object.c b/qom/object.c
index 49addefd62..33217b820f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -337,6 +337,8 @@ void object_finalize(void *data)
object_deinit(obj, ti);
object_property_del_all(obj);
+
+ g_assert(obj->ref == 0);
}
Object *object_new_with_type(Type type)
@@ -347,6 +349,7 @@ Object *object_new_with_type(Type type)
obj = g_malloc(type->instance_size);
object_initialize_with_type(obj, type);
+ object_ref(obj);
return obj;
}
@@ -360,7 +363,8 @@ Object *object_new(const char *typename)
void object_delete(Object *obj)
{
- object_finalize(obj);
+ object_unref(obj);
+ g_assert(obj->ref == 0);
g_free(obj);
}
@@ -679,6 +683,14 @@ static void object_get_child_property(Object *obj, Visitor *v, void *opaque,
g_free(path);
}
+static void object_finalize_child_property(Object *obj, const char *name,
+ void *opaque)
+{
+ Object *child = opaque;
+
+ object_unref(child);
+}
+
void object_property_add_child(Object *obj, const char *name,
Object *child, Error **errp)
{
@@ -687,7 +699,7 @@ void object_property_add_child(Object *obj, const char *name,
type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
object_property_add(obj, name, type, object_get_child_property,
- NULL, NULL, child, errp);
+ NULL, object_finalize_child_property, child, errp);
object_ref(child);
g_assert(child->parent == NULL);