[geany/geany] e5bb65: plugins: when loading active ones, loop until no more proxy plugins are added

Thomas Martitz git-noreply at xxxxx
Mon Oct 5 20:11:12 UTC 2015


Branch:      refs/heads/master
Author:      Thomas Martitz <kugel at rockbox.org>
Committer:   Thomas Martitz <kugel at rockbox.org>
Date:        Mon, 05 Oct 2015 20:11:12 UTC
Commit:      e5bb6571c60be2169c3d66ae38c72d72709bf10e
             https://github.com/geany/geany/commit/e5bb6571c60be2169c3d66ae38c72d72709bf10e

Log Message:
-----------
plugins: when loading active ones, loop until no more proxy plugins are added

During the loading of the active plugins they are also initialized (done at
startup). As a result, these plugins could be pluxys and make more plugins
available, some of which may be active as well.

Because of this the loop has to be restarted if pluxies become
available to also load active plugins that depend on the pluxy.

The loop is only restarted at the end so only nested pluxys could possibly
cause the loop to be run more than twice.


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

Modified: src/plugins.c
37 lines changed, 22 insertions(+), 15 deletions(-)
===================================================================
@@ -964,31 +964,38 @@ static PluginProxy* is_plugin(const gchar *file)
 static void
 load_active_plugins(void)
 {
-	guint i, len;
+	guint i, len, proxies;
 
 	if (active_plugins_pref == NULL || (len = g_strv_length(active_plugins_pref)) == 0)
 		return;
 
-	for (i = 0; i < len; i++)
+	/* If proxys are loaded we have to restart to load plugins that sort before their proxy */
+	do
 	{
-		const gchar *fname = active_plugins_pref[i];
+		proxies = active_proxies->len;
+		g_list_free_full(failed_plugins_list, (GDestroyNotify) g_free);
+		failed_plugins_list = NULL;
+		for (i = 0; i < len; i++)
+		{
+			gchar *fname = active_plugins_pref[i];
 
 #ifdef G_OS_WIN32
-		/* ensure we have canonical paths */
-		gchar *p = fname;
-		while ((p = strchr(p, '/')) != NULL)
-			*p = G_DIR_SEPARATOR;
+			/* ensure we have canonical paths */
+			gchar *p = fname;
+			while ((p = strchr(p, '/')) != NULL)
+				*p = G_DIR_SEPARATOR;
 #endif
 
-		if (!EMPTY(fname) && g_file_test(fname, G_FILE_TEST_EXISTS))
-		{
-			PluginProxy *proxy = NULL;
-			if (check_plugin_path(fname))
-				proxy = is_plugin(fname);
-			if (proxy == NULL || plugin_new(proxy->plugin, fname, TRUE, FALSE) == NULL)
-				failed_plugins_list = g_list_prepend(failed_plugins_list, g_strdup(fname));
+			if (!EMPTY(fname) && g_file_test(fname, G_FILE_TEST_EXISTS))
+			{
+				PluginProxy *proxy = NULL;
+				if (check_plugin_path(fname))
+					proxy = is_plugin(fname);
+				if (proxy == NULL || plugin_new(proxy->plugin, fname, TRUE, FALSE) == NULL)
+					failed_plugins_list = g_list_prepend(failed_plugins_list, g_strdup(fname));
+			}
 		}
-	}
+	} while (proxies != active_proxies->len);
 }
 
 



--------------
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