Initialize provider_table in camel in case we haven't already
authorTobias Mueller <tobiasmue@gnome.org>
Fri, 8 Aug 2008 14:39:50 +0000 (16:39 +0200)
committerTobias Mueller <tobiasmue@gnome.org>
Sun, 10 May 2009 04:31:51 +0000 (06:31 +0200)
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
camel/camel-provider.c

index 4418262..2645c84 100644 (file)
@@ -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) {
index ca6b74c..db20688 100644 (file)
@@ -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);