[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 47/59] object: release all props
From: |
Paolo Bonzini |
Subject: |
[PULL 47/59] object: release all props |
Date: |
Thu, 23 Jan 2020 14:48:50 +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 202d576..84d234d 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 34/59] qdev: move helper function to monitor/misc, (continued)
- [PULL 34/59] qdev: move helper function to monitor/misc, Paolo Bonzini, 2020/01/23
- [PULL 35/59] object: avoid extra class property key duplication, Paolo Bonzini, 2020/01/23
- [PULL 36/59] object: add class property initializer, Paolo Bonzini, 2020/01/23
- [PULL 37/59] object: add object_property_get_defaut(), Paolo Bonzini, 2020/01/23
- [PULL 38/59] object: make object_class_property_add* return property, Paolo Bonzini, 2020/01/23
- [PULL 39/59] qstring: add qstring_free(), Paolo Bonzini, 2020/01/23
- [PULL 40/59] object: add object_property_set_defaut_{bool, str, int, uint}(), Paolo Bonzini, 2020/01/23
- [PULL 41/59] object: do not free class properties, Paolo Bonzini, 2020/01/23
- [PULL 42/59] object: check strong flag with &, Paolo Bonzini, 2020/01/23
- [PULL 43/59] object: rename link "child" to "target", Paolo Bonzini, 2020/01/23
- [PULL 47/59] object: release all props,
Paolo Bonzini <=
- [PULL 44/59] object: add direct link flag, Paolo Bonzini, 2020/01/23
- [PULL 45/59] object: express const link with link property, Paolo Bonzini, 2020/01/23
- [PULL 48/59] object: return self in object_ref(), Paolo Bonzini, 2020/01/23
- [PULL 46/59] object: add object_class_property_add_link(), Paolo Bonzini, 2020/01/23
- [PULL 50/59] qdev: move instance properties to class properties, Paolo Bonzini, 2020/01/23
- [PULL 49/59] qdev: set properties with device_class_set_props(), Paolo Bonzini, 2020/01/23