[libpeas] Don't warn when loading an uninstalled plugin loader
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Don't warn when loading an uninstalled plugin loader
- Date: Tue, 20 Jan 2015 09:23:31 +0000 (UTC)
commit 06a14dc39929bde4a4790bc8562156edb1aa608a
Author: Garrett Regier <garrettregier gmail com>
Date: Sun Jan 18 05:05:07 2015 -0800
Don't warn when loading an uninstalled plugin loader
This removes the only global log hook in the test suite.
libpeas/peas-dirs.c | 4 +-
libpeas/peas-dirs.h | 8 +++---
libpeas/peas-engine.c | 40 +++++++++---------------------------
tests/testing-util/testing-util.c | 40 ++++--------------------------------
4 files changed, 21 insertions(+), 71 deletions(-)
---
diff --git a/libpeas/peas-dirs.c b/libpeas/peas-dirs.c
index 23e17e0..df6713e 100644
--- a/libpeas/peas-dirs.c
+++ b/libpeas/peas-dirs.c
@@ -157,7 +157,7 @@ peas_dirs_get_lib_dir (void)
}
gchar *
-peas_dirs_get_plugin_loaders_dir (void)
+peas_dirs_get_plugin_loader_dir (const gchar *loader_name)
{
const gchar *env_var;
gchar *lib_dir;
@@ -165,7 +165,7 @@ peas_dirs_get_plugin_loaders_dir (void)
env_var = g_getenv ("PEAS_PLUGIN_LOADERS_DIR");
if (env_var != NULL)
- return g_strdup (env_var);
+ return g_build_filename (env_var, loader_name, NULL);
lib_dir = peas_dirs_get_lib_dir ();
loader_dir = g_build_filename (lib_dir, "loaders", NULL);
diff --git a/libpeas/peas-dirs.h b/libpeas/peas-dirs.h
index da4cfa0..5b39a76 100644
--- a/libpeas/peas-dirs.h
+++ b/libpeas/peas-dirs.h
@@ -27,10 +27,10 @@
G_BEGIN_DECLS
-gchar *peas_dirs_get_data_dir (void);
-gchar *peas_dirs_get_lib_dir (void);
-gchar *peas_dirs_get_plugin_loaders_dir (void);
-gchar *peas_dirs_get_locale_dir (void);
+gchar *peas_dirs_get_data_dir (void);
+gchar *peas_dirs_get_lib_dir (void);
+gchar *peas_dirs_get_plugin_loader_dir (const gchar *loader_name);
+gchar *peas_dirs_get_locale_dir (void);
G_END_DECLS
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 54a0f46..6af38e7 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -645,24 +645,6 @@ peas_engine_class_init (PeasEngineClass *klass)
}
static PeasObjectModule *
-load_module (const gchar *module_name,
- const gchar *module_dir)
-{
- PeasObjectModule *module;
-
- /* Bind loaders globally, binding
- * locally can break the plugin loaders
- */
- module = peas_object_module_new_full (module_name, module_dir,
- TRUE, FALSE);
-
- if (!g_type_module_use (G_TYPE_MODULE (module)))
- g_clear_object (&module);
-
- return module;
-}
-
-static PeasObjectModule *
get_plugin_loader_module (gint loader_id)
{
GlobalLoaderInfo *global_loader_info = &loaders[loader_id];
@@ -675,7 +657,7 @@ get_plugin_loader_module (gint loader_id)
loader_name = peas_utils_get_loader_from_id (loader_id);
module_name = g_strconcat (loader_name, "loader", NULL);
- module_dir = peas_dirs_get_plugin_loaders_dir ();
+ module_dir = peas_dirs_get_plugin_loader_dir (loader_name);
/* Remove '.'s from the module name */
for (i = 0, j = 0; module_name[i] != '\0'; ++i)
@@ -686,24 +668,22 @@ get_plugin_loader_module (gint loader_id)
module_name[j] = '\0';
- global_loader_info->module = load_module (module_name, module_dir);
+ /* Bind loaders globally, binding
+ * locally can break the plugin loaders
+ */
+ global_loader_info->module = peas_object_module_new_full (module_name,
+ module_dir,
+ TRUE, FALSE);
- if (global_loader_info->module == NULL)
+ if (!g_type_module_use (G_TYPE_MODULE (global_loader_info->module)))
{
- gchar *tmp = module_dir;
-
- module_dir = g_build_filename (module_dir, loader_name, NULL);
- global_loader_info->module = load_module (module_name, module_dir);
-
- g_free (tmp);
+ g_warning ("Could not load plugin loader '%s'", loader_name);
+ g_clear_object (&global_loader_info->module);
}
g_free (module_dir);
g_free (module_name);
- if (global_loader_info->module == NULL)
- g_warning ("Could not load plugin loader '%s'", loader_name);
-
return global_loader_info->module;
}
diff --git a/tests/testing-util/testing-util.c b/tests/testing-util/testing-util.c
index 383603b..b616673 100644
--- a/tests/testing-util/testing-util.c
+++ b/tests/testing-util/testing-util.c
@@ -55,19 +55,6 @@ static GPrivate engine_key = G_PRIVATE_INIT (engine_private_notify);
static GPrivate unhandled_key = G_PRIVATE_INIT (unhandled_private_notify);
static GPrivate log_hooks_key = G_PRIVATE_INIT (log_hooks_private_notify);
-/* These are warnings and criticals that just have to happen
- * for testing purposes and as such we don't want to abort on them.
- *
- * If the warnings are for specific tests use
- * testing_util_push_log_hook() and testing_util_pop_log_hook() which
- * will assert that the warning or critical actually happened.
- *
- * Don't bother putting errors in here as GLib always aborts on errors.
- */
-static const gchar *allowed_patterns[] = {
- "Failed to load module '*loader'*"
-};
-
static void
engine_private_notify (gpointer value)
{
@@ -125,7 +112,6 @@ log_handler (const gchar *log_domain,
{
LogHooks *log_hooks = get_log_hooks ();
GPtrArray *hooks = log_hooks->hooks;
- gboolean found = FALSE;
guint i;
/* We always want to log debug, info and message logs */
@@ -149,34 +135,18 @@ log_handler (const gchar *log_domain,
for (i = 0; i < hooks->len; ++i)
{
LogHook *hook = g_ptr_array_index (hooks, i);
-
- if (g_pattern_match_simple (hook->pattern, message))
- {
- hook->hit = TRUE;
- found = TRUE;
- break;
- }
- }
-
- /* Check the allowed_patterns after the log hooks to
- * avoid issues when an allowed_pattern would match a hook
- */
- for (i = 0; i < G_N_ELEMENTS (allowed_patterns) && !found; ++i)
- {
- if (g_pattern_match_simple (allowed_patterns[i], message))
- found = TRUE;
- }
-
- if (found)
- {
gchar *msg;
+ if (!g_pattern_match_simple (hook->pattern, message))
+ continue;
+
msg = g_strdup_printf ("%s-%s: %s", log_domain,
(log_level & G_LOG_LEVEL_WARNING) != 0 ?
"WARNING" : "CRITICAL",
message);
-
g_ptr_array_add (log_hooks->hits, msg);
+
+ hook->hit = TRUE;
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]