[gegl/soc-2013-opecl-ops] operation: Move the hash table creation to gegl_init
- From: Carlos Zubieta <czubieta src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/soc-2013-opecl-ops] operation: Move the hash table creation to gegl_init
- Date: Wed, 11 Sep 2013 12:21:58 +0000 (UTC)
commit 00c8c3381e404e0f225c4187d4c80cff97805ae9
Author: Michael Henning <drawoc darkrefraction com>
Date: Tue Aug 6 22:46:59 2013 -0400
operation: Move the hash table creation to gegl_init
gegl/gegl-init.c | 1 +
gegl/operation/gegl-operations.c | 21 +++++++++++----------
gegl/operation/gegl-operations.h | 1 +
3 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index fb07890..4c6e880 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -212,6 +212,7 @@ gegl_init (gint *argc,
initialized = TRUE;
gegl_init_i18n ();
+ gegl_operation_gtype_init ();
context = g_option_context_new (NULL);
g_option_context_set_ignore_unknown_options (context, TRUE);
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]