[geany/geany] 6cb443: plugins: enforce geany_plugin_register_proxy() can be called once

Thomas Martitz git-noreply at xxxxx
Tue Oct 6 13:40:57 UTC 2015


Branch:      refs/heads/master
Author:      Thomas Martitz <kugel at rockbox.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 06 Oct 2015 13:40:57 UTC
Commit:      6cb443e8631681c7b74ccef25c7656bdbc9f9305
             https://github.com/geany/geany/commit/6cb443e8631681c7b74ccef25c7656bdbc9f9305

Log Message:
-----------
plugins: enforce geany_plugin_register_proxy() can be called once

In the future we might want to enable calling it again to set new supported
plugin types/extensions. This is not implemented yet, but in order to
allow this in the future we have to prevent it now, otherwise we'd
need to break the API.


Modified Paths:
--------------
    src/plugins.c

Modified: src/plugins.c
11 lines changed, 10 insertions(+), 1 deletions(-)
===================================================================
@@ -1985,6 +1985,8 @@ gboolean geany_plugin_register_proxy(GeanyPlugin *plugin, const gchar **extensio
 {
 	Plugin *p;
 	const gchar **ext;
+	PluginProxy *proxy;
+	GList *node;
 
 	g_return_val_if_fail(plugin != NULL, FALSE);
 	g_return_val_if_fail(extensions != NULL, FALSE);
@@ -1993,10 +1995,17 @@ gboolean geany_plugin_register_proxy(GeanyPlugin *plugin, const gchar **extensio
 	g_return_val_if_fail(plugin->proxy_funcs->unload != NULL, FALSE);
 
 	p = plugin->priv;
+	/* Check if this was called aready. We want to reserve for the use case of calling
+	 * this again to set new supported extensions (for example, based on proxy configuration). */
+	foreach_list(node, active_proxies.head)
+	{
+		proxy = node->data;
+		g_return_if_fail(p != proxy->plugin);
+	}
 
 	foreach_strv(ext, extensions)
 	{
-		PluginProxy *proxy = g_new(PluginProxy, 1);
+		proxy = g_new(PluginProxy, 1);
 		g_strlcpy(proxy->extension, *ext, sizeof(proxy->extension));
 		proxy->plugin = p;
 		/* prepend, so that plugins automatically override core providers for a given extension */



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list