Fail to load a plugin if it has no plugin_init() function.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2618 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-05-27 14:47:38 +00:00
parent a87b2e57b9
commit c553028808
2 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2008-05-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/plugins.c:
Fail to load a plugin if it has no plugin_init() function.
2008-05-26 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/plugins.c:

View File

@ -470,11 +470,8 @@ plugin_init(Plugin *plugin)
*plugin_fields = &plugin->fields;
/* start the plugin */
g_module_symbol(plugin->module, "plugin_init", (void *) &plugin->init);
if (plugin->init != NULL)
plugin->init(&geany_data);
else
geany_debug("Plugin '%s' has no plugin_init() function!", plugin->info.name);
g_return_if_fail(plugin->init);
plugin->init(&geany_data);
/* store some function pointers for later use */
g_module_symbol(plugin->module, "configure", (void *) &plugin->configure);
@ -511,7 +508,7 @@ plugin_init(Plugin *plugin)
}
/* Load and init a plugin.
/* Load and optionally init a plugin.
* init_plugin decides whether the plugin's plugin_init() function should be called or not. If it is
* called, the plugin will be started, if not the plugin will be read only (for the list of
* available plugins in the plugin manager).
@ -590,6 +587,18 @@ plugin_new(const gchar *fname, gboolean init_plugin, gboolean add_to_list)
g_free(plugin);
return NULL;
}
g_module_symbol(module, "plugin_init", (void *) &plugin->init);
if (plugin->init == NULL)
{
geany_debug("Plugin '%s' has no plugin_init() function - ignoring plugin!",
plugin->info.name);
if (! g_module_close(module))
g_warning("%s: %s", fname, g_module_error());
g_free(plugin);
return NULL;
}
geany_debug("Initializing plugin '%s'", plugin->info.name);
plugin->filename = g_strdup(fname);