[libpeas] Warn if creating an extension fails
- From: Steve Frécinaux <sfre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Warn if creating an extension fails
- Date: Sun, 6 Mar 2011 12:58:21 +0000 (UTC)
commit 63153f709e4ed60a6e895ac00f6631094f1ae97b
Author: Garrett Regier <alias301 gmail com>
Date: Fri Mar 4 22:47:19 2011 -0800
Warn if creating an extension fails
libpeas/peas-engine.c | 15 +++++++++++++--
libpeas/peas-extension-set.c | 6 ++++--
loaders/python/peas-plugin-loader-python.c | 3 +--
tests/libpeas/testing/testing-extension.c | 14 +++++++++-----
4 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index be848fb..93b99c6 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -979,6 +979,7 @@ peas_engine_create_extensionv (PeasEngine *engine,
GParameter *parameters)
{
PeasPluginLoader *loader;
+ PeasExtension *extension;
g_return_val_if_fail (PEAS_IS_ENGINE (engine), NULL);
g_return_val_if_fail (info != NULL, NULL);
@@ -986,8 +987,18 @@ peas_engine_create_extensionv (PeasEngine *engine,
g_return_val_if_fail (G_TYPE_IS_INTERFACE (extension_type), FALSE);
loader = get_plugin_loader (engine, info);
- return peas_plugin_loader_create_extension (loader, info, extension_type,
- n_parameters, parameters);
+ extension = peas_plugin_loader_create_extension (loader, info, extension_type,
+ n_parameters, parameters);
+
+ if (!PEAS_IS_EXTENSION (extension))
+ {
+ g_warning ("Plugin '%s' does not provide a '%s' extension",
+ peas_plugin_info_get_module_name (info),
+ g_type_name (extension_type));
+ return NULL;
+ }
+
+ return extension;
}
/**
diff --git a/libpeas/peas-extension-set.c b/libpeas/peas-extension-set.c
index 8f4b75b..6dd9018 100644
--- a/libpeas/peas-extension-set.c
+++ b/libpeas/peas-extension-set.c
@@ -198,12 +198,14 @@ add_extension (PeasExtensionSet *set,
if (!peas_plugin_info_is_loaded (info))
return;
+ if (!peas_engine_provides_extension (set->priv->engine, info,
+ set->priv->exten_type))
+ return;
+
exten = peas_engine_create_extensionv (set->priv->engine, info,
set->priv->exten_type,
set->priv->n_parameters,
set->priv->parameters);
- if (!exten)
- return;
/* peas_plugin_info_ref (info); */
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index 95de6b9..ddfa949 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -106,8 +106,7 @@ find_python_extension_type (PeasPluginInfo *info,
}
Py_DECREF (pygtype);
- g_debug ("No '%s' derivative found in Python plugin '%s'",
- g_type_name (exten_type), peas_plugin_info_get_name (info));
+
return NULL;
}
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c
index 0b6ca14..5ae51a3 100644
--- a/tests/libpeas/testing/testing-extension.c
+++ b/tests/libpeas/testing/testing-extension.c
@@ -156,7 +156,6 @@ void
testing_extension_create_invalid_ (PeasEngine *engine)
{
PeasPluginInfo *info;
- PeasExtension *extension;
info = peas_engine_get_plugin_info (engine, extension_plugin);
@@ -193,10 +192,15 @@ testing_extension_create_invalid_ (PeasEngine *engine)
/* Does not implement this GType */
- extension = peas_engine_create_extension (engine, info,
- INTROSPECTION_TYPE_UNIMPLEMENTED,
- NULL);
- g_assert (!PEAS_IS_EXTENSION (extension));
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+ {
+ peas_engine_create_extension (engine, info,
+ INTROSPECTION_TYPE_UNIMPLEMENTED,
+ NULL);
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*WARNING*");
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]