From 2ac43f391aca1a916b37f66e293c2f8fd051902b Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Wed, 21 Apr 2021 11:31:29 +0200 Subject: [PATCH] manager: Set peas search path only once There is no need to redo it for every added plugin. --- src/calls-manager.c | 15 +++++++++++++++ src/calls-provider.c | 10 ---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/calls-manager.c b/src/calls-manager.c index bb108b1..4023a8b 100644 --- a/src/calls-manager.c +++ b/src/calls-manager.c @@ -471,6 +471,9 @@ calls_manager_class_init (CallsManagerClass *klass) static void calls_manager_init (CallsManager *self) { + PeasEngine *peas; + const gchar *dir; + self->state = CALLS_MANAGER_STATE_NO_PROVIDER; self->provider_name = NULL; self->primary_call = NULL; @@ -480,6 +483,18 @@ calls_manager_init (CallsManager *self) g_object_bind_property (self, "country-code", self->contacts_provider, "country-code", G_BINDING_DEFAULT); + + // Prepend peas plugin search path + peas = peas_engine_get_default (); + peas_engine_add_search_path (peas, PLUGIN_LIBDIR, NULL); + g_debug ("Scanning for plugins in `%s'", PLUGIN_LIBDIR); + + dir = g_getenv ("CALLS_PLUGIN_DIR"); + if (dir && dir[0] != '\0') { + g_debug ("Adding %s to plugin search path", dir); + peas_engine_prepend_search_path (peas, dir, NULL); + } + } diff --git a/src/calls-provider.c b/src/calls-provider.c index 53c08e9..db31436 100644 --- a/src/calls-provider.c +++ b/src/calls-provider.c @@ -174,18 +174,8 @@ calls_provider_load_plugin (const char *name) PeasEngine *plugins; PeasPluginInfo *info; PeasExtension *extension; - const gchar *dir; - // Add Calls search path and rescan plugins = peas_engine_get_default (); - peas_engine_add_search_path (plugins, PLUGIN_LIBDIR, NULL); - g_debug ("Scanning for plugins in `%s'", PLUGIN_LIBDIR); - - dir = g_getenv ("CALLS_PLUGIN_DIR"); - if (dir && dir[0] != '\0') { - g_debug ("Adding %s to plugin search path", dir); - peas_engine_prepend_search_path (plugins, dir, NULL); - } // Find the plugin info = peas_engine_get_plugin_info (plugins, name);