From 8b7140f2a9b43e003152e73f69eca1468ba750bf Mon Sep 17 00:00:00 2001 From: Thynson Date: Fri, 16 Dec 2011 23:32:23 +0800 Subject: plugin: avoid plugins to be loaded twice The original implementation will load plugins from both (XDG_LOCAL_HOME|HOME)/.local/lib/deadbeef and configured path, the latter is ussualy in $PREFIX/lib/deadbeef. However if the deadbeef is configured to be installed in $HOME/.local, it may cause the each plugin will be load twice. Despite that there must be a bug in a plugin which is not reentrant, it should avoid this anyway. --- plugins.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plugins.c') diff --git a/plugins.c b/plugins.c index d41b0777..a83fb64c 100644 --- a/plugins.c +++ b/plugins.c @@ -779,6 +779,14 @@ plug_load_all (void) { // load from HOME 1st, than replace from installdir if needed const char *plugins_dirs[] = { xdg_plugin_dir, dirname, NULL }; + + // If xdg_plugin_dir and dirname is the same, we should avoid each plugin + // to be load twice. + // XXX: Here absolute path is assumed, however if dirname is a relative + // path it won't work. + if (strcmp(xdg_plugin_dir, dirname) == 0) { + plugins_dirs[1] = NULL; + } #else const char *plugins_dirs[] = { dirname, NULL }; #endif -- cgit v1.2.3