[gegl] Revert "operation: Move the hash table creation to gegl_init"



commit b0fd1a6dd2b7e707822dc1736daecd496d339773
Author: Michael Henning <drawoc darkrefraction com>
Date:   Tue Aug 6 23:02:08 2013 -0400

    Revert "operation: Move the hash table creation to gegl_init"
    
    This reverts commit eefb4748813b1509b456d7075dd557f7e9adf5d9.

 gegl/gegl-init.c                 |    1 -
 gegl/operation/gegl-operations.c |   21 ++++++++++-----------
 gegl/operation/gegl-operations.h |    1 -
 3 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index 4c6e880..fb07890 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -212,7 +212,6 @@ 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 410dbda..5a6d340 100644
--- a/gegl/operation/gegl-operations.c
+++ b/gegl/operation/gegl-operations.c
@@ -48,6 +48,12 @@ 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)
     {
@@ -103,6 +109,10 @@ 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);
 }
 
@@ -151,17 +161,6 @@ 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 58c373a..821ae07 100644
--- a/gegl/operation/gegl-operations.h
+++ b/gegl/operation/gegl-operations.h
@@ -27,7 +27,6 @@
  */
 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]