[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 46/59] object: release all props
From: |
Paolo Bonzini |
Subject: |
[PULL 46/59] object: release all props |
Date: |
Thu, 23 Jan 2020 14:50:36 +0100 |
From: Marc-André Lureau <address@hidden>
Class properties may have to release resources when the object is
destroyed. Let's use the existing release() callback for that, but
class properties must not release ObjectProperty, as it can be shared
by various instances.
Signed-off-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qom/object.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index a3da546..66c4a5f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -592,23 +592,22 @@ static inline bool
object_property_is_child(ObjectProperty *prop)
static void object_property_del_all(Object *obj)
{
+ g_autoptr(GHashTable) done = g_hash_table_new(NULL, NULL);
ObjectProperty *prop;
- GHashTableIter iter;
- gpointer key, value;
+ ObjectPropertyIterator iter;
bool released;
do {
released = false;
- g_hash_table_iter_init(&iter, obj->properties);
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- prop = value;
- if (prop->release) {
- prop->release(obj, prop->name, prop->opaque);
- prop->release = NULL;
- released = true;
- break;
+ object_property_iter_init(&iter, obj);
+ while ((prop = object_property_iter_next(&iter)) != NULL) {
+ if (g_hash_table_add(done, prop)) {
+ if (prop->release) {
+ prop->release(obj, prop->name, prop->opaque);
+ released = true;
+ break;
+ }
}
- g_hash_table_iter_remove(&iter);
}
} while (released);
--
1.8.3.1
- [PULL 36/59] object: add class property initializer, (continued)
- [PULL 36/59] object: add class property initializer, Paolo Bonzini, 2020/01/23
- [PULL 37/59] object: make object_class_property_add* return property, Paolo Bonzini, 2020/01/23
- [PULL 38/59] qstring: add qstring_free(), Paolo Bonzini, 2020/01/23
- [PULL 39/59] object: add object_property_set_default, Paolo Bonzini, 2020/01/23
- [PULL 40/59] object: do not free class properties, Paolo Bonzini, 2020/01/23
- [PULL 41/59] object: check strong flag with &, Paolo Bonzini, 2020/01/23
- [PULL 42/59] object: rename link "child" to "target", Paolo Bonzini, 2020/01/23
- [PULL 43/59] object: add direct link flag, Paolo Bonzini, 2020/01/23
- [PULL 44/59] object: express const link with link property, Paolo Bonzini, 2020/01/23
- [PULL 45/59] object: add object_class_property_add_link(), Paolo Bonzini, 2020/01/23
- [PULL 46/59] object: release all props,
Paolo Bonzini <=
- [PULL 47/59] object: return self in object_ref(), Paolo Bonzini, 2020/01/23
- [PULL 49/59] qdev: rename DeviceClass.props, Paolo Bonzini, 2020/01/23
- [PULL 50/59] qdev: move instance properties to class properties, Paolo Bonzini, 2020/01/23
- [PULL 52/59] vl: print default value in object help, Paolo Bonzini, 2020/01/23
- [PULL 51/59] qdev: register properties as class properties, Paolo Bonzini, 2020/01/23
- [PULL 53/59] qom: simplify qmp_device_list_properties(), Paolo Bonzini, 2020/01/23
- [PULL 54/59] qom: introduce object_property_help(), Paolo Bonzini, 2020/01/23
- [PULL 55/59] qapi/qmp: add ObjectPropertyInfo.default-value, Paolo Bonzini, 2020/01/23
- [PULL 56/59] qdev: use object_property_help(), Paolo Bonzini, 2020/01/23
- [PULL 57/59] target/i386: Add the 'model-id' for Skylake -v3 CPU models, Paolo Bonzini, 2020/01/23