[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 17/26] object: release all props
From: |
Marc-André Lureau |
Subject: |
[PATCH 17/26] object: release all props |
Date: |
Fri, 10 Jan 2020 19:30:30 +0400 |
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>
---
qom/object.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 04f2991716..3924678ec3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -583,23 +583,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);
--
2.25.0.rc1.20.g2443f3f80d.dirty
- [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}(), (continued)
- [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}(), Marc-André Lureau, 2020/01/10
- Re: [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}(), Paolo Bonzini, 2020/01/23
- Re: [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}(), Marc-André Lureau, 2020/01/23
- Re: [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}(), Paolo Bonzini, 2020/01/23
- [PATCH 11/26] object: do not free class properties, Marc-André Lureau, 2020/01/10
- [PATCH 12/26] object: check strong flag with &, Marc-André Lureau, 2020/01/10
- [PATCH 13/26] object: rename link "child" to "target", Marc-André Lureau, 2020/01/10
- [PATCH 14/26] object: add direct link flag, Marc-André Lureau, 2020/01/10
- [PATCH 15/26] object: express const link with link property, Marc-André Lureau, 2020/01/10
- [PATCH 16/26] object: add object_class_property_add_link(), Marc-André Lureau, 2020/01/10
- [PATCH 17/26] object: release all props,
Marc-André Lureau <=
- [PATCH 18/26] object: return self in object_ref(), Marc-André Lureau, 2020/01/10
- [PATCH 20/26] qdev: move instance properties to class properties, Marc-André Lureau, 2020/01/10
- [PATCH 21/26] qdev: register properties as class properties, Marc-André Lureau, 2020/01/10
- [PATCH 19/26] qdev: set properties with device_class_set_props(), Marc-André Lureau, 2020/01/10
- [PATCH 22/26] vl: print default value in object help, Marc-André Lureau, 2020/01/10
- [PATCH 23/26] qom: simplify qmp_device_list_properties(), Marc-André Lureau, 2020/01/10
- [PATCH 24/26] qom: introduce object_property_help(), Marc-André Lureau, 2020/01/10