]> Pileus Git - grits/blobdiff - src/gis/gis-plugin.c
Lots of work on libGIS
[grits] / src / gis / gis-plugin.c
index e15c53c2b42fc3add42abb60db38c25c82de095f..4bfab58d71afb8d634ebd7b6d7a5957b180eb01e 100644 (file)
@@ -20,6 +20,9 @@
 
 #include "gis-plugin.h"
 
+/********************
+ * Plugin interface *
+ ********************/
 static void gis_plugin_base_init(gpointer g_class)
 {
        static gboolean is_initialized = FALSE;
@@ -56,7 +59,10 @@ GtkWidget *gis_plugin_get_config(GisPlugin *self)
        return GIS_PLUGIN_GET_INTERFACE(self)->get_config(self);
 }
 
-/* Plugins API */
+
+/***************
+ * Plugins API *
+ ***************/
 typedef struct {
        gchar *name;
        GisPlugin *plugin;
@@ -82,6 +88,8 @@ void gis_plugins_free(GisPlugins *self)
 GList *gis_plugins_available()
 {
        GDir *dir = g_dir_open(PLUGINDIR, 0, NULL);
+       if (dir == NULL)
+               return NULL;
        GList *list = NULL;
        const gchar *name;
        while ((name = g_dir_read_name(dir))) {
@@ -105,9 +113,9 @@ GisPlugin *gis_plugins_load(GisPlugins *self, const char *name,
                return NULL;
        }
 
-       GisPluginConstructor constructor;
+       gpointer constructor_ptr; // GCC 4.1 fix?
        gchar *constructor_str = g_strconcat("gis_plugin_", name, "_new", NULL);
-       if (!g_module_symbol(module, constructor_str, (gpointer*)&constructor)) {
+       if (!g_module_symbol(module, constructor_str, &constructor_ptr)) {
                g_warning("Unable to load symbol %s from %s: %s",
                                constructor_str, name, g_module_error());
                g_module_close(module);
@@ -115,6 +123,7 @@ GisPlugin *gis_plugins_load(GisPlugins *self, const char *name,
                return NULL;
        }
        g_free(constructor_str);
+       GisPluginConstructor constructor = constructor_ptr;
 
        GisPluginStore *store = g_malloc(sizeof(GisPluginStore));
        store->name = g_strdup(name);