[gegl] operation: fix operation-class keys hash aliasing in subclasses
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operation: fix operation-class keys hash aliasing in subclasses
- Date: Sat, 20 Jul 2019 22:45:09 +0000 (UTC)
commit e700c1e0015e9d68d8d76647c76e4cc3a6cb1798
Author: Ell <ell_se yahoo com>
Date: Sun Jul 21 01:37:37 2019 +0300
operation: fix operation-class keys hash aliasing in subclasses
Since we no longer initialize the the keys hash table for each
GeglOperation subclass in base_init(), it is inherited from the
parent class; if the parent class already set some class keys, the
inherited hash table is not NULL, and aliases that of the parent.
Hackishly fix this by storing a pointer to the owner class in the
hash table, and create a new hash table, rather than using the
existing one, in case the stored pointer doesn't match the current
class.
gegl/operation/gegl-operation.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index d12858b2e..39e6ba6e3 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -744,11 +744,18 @@ gegl_operation_class_set_key (GeglOperationClass *klass,
gegl_operation_class_register_name (klass, key_value, TRUE);
}
- if (! klass->keys)
+ if (! klass->keys ||
+ /* avoid inheriting an existing hash table from the parent class */
+ g_hash_table_lookup (klass->keys, "operation-class") != klass)
{
/* XXX: leaked for now */
klass->keys = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_free);
+
+ /* ... so we don't actually have to worry about these values being
+ * freed ...
+ */
+ g_hash_table_insert (klass->keys, "operation-class", klass);
}
g_hash_table_insert (klass->keys, g_strdup (key_name),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]