mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
object: release all props
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 <marcandre.lureau@redhat.com> Message-Id: <20200110153039.1379601-18-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
840ecdfbf9
commit
9859facc04
13
qom/object.c
13
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;
|
||||
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);
|
||||
prop->release = NULL;
|
||||
released = true;
|
||||
break;
|
||||
}
|
||||
g_hash_table_iter_remove(&iter);
|
||||
}
|
||||
}
|
||||
} while (released);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user