[gegl] operation: Move the hash table creation to gegl_init
- From: Michael Henning <mhenning src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operation: Move the hash table creation to gegl_init
- Date: Wed, 7 Aug 2013 03:11:00 +0000 (UTC)
commit 2aaacd4b7e78d369ace88713e03373581e003fe9
Author: Michael Henning <drawoc darkrefraction com>
Date: Tue Aug 6 22:46:59 2013 -0400
operation: Move the hash table creation to gegl_init
This time, call it from gegl_post_parse_hook
gegl/gegl-init.c | 2 ++
gegl/operation/gegl-operations.c | 21 +++++++++++----------
gegl/operation/gegl-operations.h | 1 +
3 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index fb07890..01db56b 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -559,6 +559,8 @@ gegl_post_parse_hook (GOptionContext *context,
GEGL_INSTRUMENT_START();
+ gegl_operation_gtype_init ();
+
if (!module_db)
{
const gchar *gegl_path = g_getenv ("GEGL_PATH");
diff --git a/gegl/operation/gegl-operations.c b/gegl/operation/gegl-operations.c
index 5a6d340..410dbda 100644
--- a/gegl/operation/gegl-operations.c
+++ b/gegl/operation/gegl-operations.c
@@ -48,12 +48,6 @@ gegl_operation_class_register_name (GeglOperationClass *klass,
G_LOCK (gtype_hash);
- /* FIXME: Maybe move initialization to gegl_init()? */
- if (!gtype_hash)
- {
- gtype_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- }
-
check_type = (GType) g_hash_table_lookup (gtype_hash, name);
if (check_type && check_type != this_type)
{
@@ -109,10 +103,6 @@ gegl_operation_gtype_from_name (const gchar *name)
gtype_hash_serial = latest_serial;
}
- /* should only happen if no operations are found */
- if (!gtype_hash)
- return G_TYPE_INVALID;
-
return (GType) g_hash_table_lookup (gtype_hash, name);
}
@@ -161,6 +151,17 @@ gchar **gegl_list_operations (guint *n_operations_p)
}
void
+gegl_operation_gtype_init (void)
+{
+ G_LOCK (gtype_hash);
+
+ if (!gtype_hash)
+ gtype_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ G_UNLOCK (gtype_hash);
+}
+
+void
gegl_operation_gtype_cleanup (void)
{
G_LOCK (gtype_hash);
diff --git a/gegl/operation/gegl-operations.h b/gegl/operation/gegl-operations.h
index 821ae07..58c373a 100644
--- a/gegl/operation/gegl-operations.h
+++ b/gegl/operation/gegl-operations.h
@@ -27,6 +27,7 @@
*/
GType gegl_operation_gtype_from_name (const gchar *name);
gchar ** gegl_list_operations (guint *n_operations_p);
+void gegl_operation_gtype_init (void);
void gegl_operation_gtype_cleanup (void);
void gegl_operation_class_register_name (GeglOperationClass *klass,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]