[evolution-data-server] Avoid loading Camel modules during introspection.



commit b53231c50730eed1518ff01d700abfb1a94ae947
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jun 5 14:16:10 2012 -0400

    Avoid loading Camel modules during introspection.

 libedataserver/e-source-camel.c |   33 ++++++++++++++++++++++-----------
 libedataserver/e-source.c       |    7 +++++--
 2 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/libedataserver/e-source-camel.c b/libedataserver/e-source-camel.c
index 107fc2d..06256c0 100644
--- a/libedataserver/e-source-camel.c
+++ b/libedataserver/e-source-camel.c
@@ -457,17 +457,9 @@ e_source_camel_init (ESourceCamel *extension)
 	extension->priv->value_array = value_array;
 }
 
-/**
- * e_source_camel_register_types:
- *
- * Creates and registers subclasses of #ESourceCamel for each available
- * #CamelProvider.  This function should be called once during application
- * or library initialization.
- *
- * Since: 3.6
- **/
-void
-e_source_camel_register_types (void)
+/* Helper for e_source_camel_register_types() */
+static gpointer
+source_camel_register_types_once (gpointer unused)
 {
 	GList *list, *link;
 
@@ -502,6 +494,25 @@ e_source_camel_register_types (void)
 	}
 
 	g_list_free (list);
+
+	return NULL;
+}
+
+/**
+ * e_source_camel_register_types:
+ *
+ * Creates and registers subclasses of #ESourceCamel for each available
+ * #CamelProvider.  This function should be called once during application
+ * or library initialization.
+ *
+ * Since: 3.6
+ **/
+void
+e_source_camel_register_types (void)
+{
+	static GOnce register_types_once = G_ONCE_INIT;
+
+	g_once (&register_types_once, source_camel_register_types_once, NULL);
 }
 
 /**
diff --git a/libedataserver/e-source.c b/libedataserver/e-source.c
index 4e668fd..18d3039 100644
--- a/libedataserver/e-source.c
+++ b/libedataserver/e-source.c
@@ -1198,8 +1198,6 @@ e_source_class_init (ESourceClass *class)
 	REGISTER_TYPE (E_TYPE_SOURCE_SMIME);
 	REGISTER_TYPE (E_TYPE_SOURCE_TASK_LIST);
 	REGISTER_TYPE (E_TYPE_SOURCE_WEBDAV);
-
-	e_source_camel_register_types ();
 }
 
 static void
@@ -1213,6 +1211,11 @@ e_source_init (ESource *source)
 {
 	GHashTable *extensions;
 
+	/* Don't do this as part of class initialization because it
+	 * loads Camel modules and can screw up introspection, which
+	 * occurs at compile-time before Camel modules are installed. */
+	e_source_camel_register_types ();
+
 	extensions = g_hash_table_new_full (
 		(GHashFunc) g_str_hash,
 		(GEqualFunc) g_str_equal,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]