[evolution-data-server] Initialize provider_table in camel in case we haven't already



commit 2f9d37fa3b167af3cc5daa77a7a27a4c0857c3b4
Author: Tobias Mueller <tobiasmue gnome org>
Date:   Fri Aug 8 16:39:50 2008 +0200

    Initialize provider_table in camel in case we haven't already
    
    Call camel_type_init in camel_provider_list in camel/camel-provider.c in
    case it we haven't already.
    Fixes bug 549094.
---
 camel/camel-object.c   |    2 ++
 camel/camel-provider.c |   11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/camel/camel-object.c b/camel/camel-object.c
index 4418262..2645c84 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -713,6 +713,8 @@ co_type_register(CamelType parent, const char * name,
 
 	TYPE_LOCK();
 
+	camel_type_init(); /* has a static boolean itself */
+
 	/* Have to check creation, it might've happened in another thread before we got here */
 	klass = g_hash_table_lookup(type_table, name);
 	if (klass != NULL) {
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index ca6b74c..db20688 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -298,7 +298,12 @@ camel_provider_list(gboolean load)
 {
 	GList *list = NULL;
 
-	g_assert(provider_table);
+
+	/* provider_table can be NULL, so initialize it */
+	if (G_UNLIKELY (provider_table == NULL))
+		camel_provider_init ();
+	
+	g_return_val_if_fail (provider_table != NULL, NULL);
 
 	LOCK();
 
@@ -344,8 +349,8 @@ camel_provider_get(const char *url_string, CamelException *ex)
 	char *protocol;
 	size_t len;
 
-	g_return_val_if_fail(url_string != NULL, NULL);
-	g_assert(provider_table);
+	g_return_val_if_fail (url_string != NULL, NULL);
+	g_return_val_if_fail (provider_table != NULL, NULL);
 
 	len = strcspn(url_string, ":");
 	protocol = g_alloca(len+1);



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