--- a/gplugin/gplugin-file-tree.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-file-tree.c Fri Mar 20 04:44:34 2020 +0000
@@ -120,11 +120,16 @@
/* now run through all of the files and add then to the dir node */
while((filename = g_dir_read_name(dir)) != NULL) {
+ gchar *test_filename = g_build_filename(path, filename, NULL); - entry = gplugin_file_tree_entry_new(filename);
- file = g_node_new(entry);
+ if(g_file_test(test_filename, G_FILE_TEST_IS_REGULAR)) { + entry = gplugin_file_tree_entry_new(filename); + file = g_node_new(entry); - g_node_prepend(node_dir, file);
+ g_node_prepend(node_dir, file); --- a/gplugin/gplugin-loader-tests.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-loader-tests.c Fri Mar 20 04:44:34 2020 +0000
@@ -110,7 +110,10 @@
ret = gplugin_manager_load_plugin(plugin, &error);
g_assert_error(error, GPLUGIN_DOMAIN, 0);
gplugin_plugin_get_state(plugin),
@@ -134,7 +137,10 @@
ret = gplugin_manager_load_plugin(plugin, &error);
g_assert_error(error, GPLUGIN_DOMAIN, 0);
gplugin_plugin_get_state(plugin),
@@ -166,7 +172,10 @@
ret = gplugin_manager_unload_plugin(plugin, &error);
g_assert_error(error, GPLUGIN_DOMAIN, 0);
gplugin_plugin_get_state(plugin),
--- a/gplugin/gplugin-manager.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-manager.c Fri Mar 20 04:44:34 2020 +0000
@@ -206,6 +206,36 @@
+gplugin_manager_foreach_unload_plugin( + G_GNUC_UNUSED gpointer data) + gchar *id = (gchar *)key; + for(l = (GList *)value; l; l = l->next) { + GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data); + GPluginLoader *loader = NULL; + if(gplugin_plugin_get_state(plugin) != GPLUGIN_PLUGIN_STATE_LOADED) { + loader = gplugin_plugin_get_loader(plugin); + if(!gplugin_loader_unload_plugin(loader, plugin, &error)) { + "failed to unload plugin with id %s: %s", + error ? error->message : "unknown"); + g_object_unref(G_OBJECT(loader)); /******************************************************************************
*****************************************************************************/
@@ -479,14 +509,11 @@
manager->loaders_by_extension,
+ if(!GPLUGIN_IS_LOADER(l->data)) { loader = GPLUGIN_LOADER(l->data);
- if(!GPLUGIN_IS_LOADER(loader)) {
/* Try to probe the plugin with the current loader */
@@ -495,7 +522,7 @@
/* Check the GError, if it's set, output its message and
- if(plugin == NULL || error) {
error_message = g_strdup_printf(
@@ -557,8 +584,13 @@
error_message = g_strdup_printf(
_("Plugin %s has a NULL id."),
+ g_object_unref(G_OBJECT(info)); g_list_prepend(error_messages, error_message);
/* now insert into our view */
@@ -570,7 +602,7 @@
/* Grab the list of plugins with our id and prepend the new
* plugin to it before updating it.
- l = g_hash_table_lookup(manager->plugins, id); //-V1004
+ l = g_hash_table_lookup(manager->plugins, id); for(ll = l; ll; ll = ll->next) {
GPluginPlugin *splugin = GPLUGIN_PLUGIN(ll->data);
gchar *sfilename = gplugin_plugin_get_filename(splugin);
@@ -627,6 +659,11 @@
g_object_unref(G_OBJECT(info));
+ /* since the plugin is now stored in our hash tables we + * need to remove this function's reference to it. + g_object_unref(G_OBJECT(plugin)); @@ -655,17 +692,8 @@
g_return_val_if_fail(id != NULL, NULL);
- for(l = g_hash_table_lookup(manager->plugins, id); l; l = l->next) {
- GPluginPlugin *plugin = NULL;
- plugin = GPLUGIN_PLUGIN(l->data);
- g_slist_prepend(plugins_list, g_object_ref(G_OBJECT(plugin)));
+ l = g_hash_table_lookup(manager->plugins, id); + plugins_list = g_slist_copy_deep(l, (GCopyFunc)g_object_ref, NULL); @@ -711,9 +739,13 @@
GPluginPlugin *dependency = GPLUGIN_PLUGIN(l->data);
- loaded = gplugin_manager_load_plugin(dependency, error);
+ loaded = gplugin_manager_load_plugin(dependency, &ourerror);
+ if(!loaded || ourerror != NULL) { + g_propagate_error(error, ourerror); @@ -737,6 +769,7 @@
info = gplugin_plugin_get_info(plugin);
dependencies = gplugin_plugin_info_get_dependencies(info);
+ g_object_unref(G_OBJECT(info)); if(dependencies == NULL) {
@@ -796,14 +829,10 @@
g_slist_free_full(ret, g_object_unref);
- g_object_unref(G_OBJECT(info));
- g_object_unref(G_OBJECT(info));
@@ -826,12 +855,15 @@
/* now try to get the plugin info from the plugin */
info = gplugin_plugin_get_info(plugin);
+ gchar *filename = gplugin_plugin_get_filename(plugin); _("Plugin %s did not return value plugin info"),
- gplugin_plugin_get_filename(plugin));
gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOAD_FAILED);
@@ -850,13 +882,16 @@
loader = gplugin_plugin_get_loader(plugin);
if(!GPLUGIN_IS_LOADER(loader)) {
+ gchar *filename = gplugin_plugin_get_filename(plugin); _("The loader for %s is not a loader. This "
- gplugin_plugin_get_filename(plugin));
gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOAD_FAILED);
@@ -941,7 +976,7 @@
/******************************************************************************
+ * GObject Implementation *****************************************************************************/
gplugin_manager_finalize(GObject *obj)
@@ -951,6 +986,12 @@
g_queue_free_full(manager->paths, g_free);
+ /* unload all of the loaded plugins */ + gplugin_manager_foreach_unload_plugin, /* free all the data in the plugins hash table and destroy it */
g_hash_table_foreach_remove(
@@ -1651,8 +1692,8 @@
* Returns a #GList of all plugin id's. Each id should be queried directly
- * Return value: (element-type utf8) (transfer full): A #GList of each unique
+ * Return value: (element-type utf8) (transfer container): A #GList of each gplugin_manager_list_plugins(void)
--- a/gplugin/gplugin-native-loader.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-native-loader.c Fri Mar 20 04:44:34 2020 +0000
@@ -241,9 +241,6 @@
- /* claim ownership of the info object */
- g_object_ref_sink(G_OBJECT(info));
/* now create the actual plugin instance */
@@ -261,6 +258,7 @@
g_object_unref(G_OBJECT(info));
if(!GPLUGIN_IS_NATIVE_PLUGIN(plugin)) {
+ g_module_close(module); @@ -311,10 +309,12 @@
/* validate the function */
- const char *filename = gplugin_plugin_get_filename(plugin);
+ gchar *filename = gplugin_plugin_get_filename(plugin); g_warning(_("unload function for %s is NULL"), filename);
--- a/gplugin/gplugin-native-plugin.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-native-plugin.c Fri Mar 20 04:44:34 2020 +0000
@@ -196,6 +196,8 @@
g_clear_object(&plugin->loader);
g_clear_object(&plugin->info);
+ g_module_close(plugin->module); G_OBJECT_CLASS(gplugin_native_plugin_parent_class)->finalize(obj);
--- a/gplugin/gplugin-plugin-info.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-plugin-info.c Fri Mar 20 04:44:34 2020 +0000
@@ -109,7 +109,7 @@
G_DEFINE_TYPE_WITH_PRIVATE(
- G_TYPE_INITIALLY_UNOWNED)
/******************************************************************************
@@ -477,6 +477,7 @@
g_clear_pointer(&priv->authors, g_strfreev);
g_clear_pointer(&priv->website, g_free);
g_clear_pointer(&priv->dependencies, g_strfreev);
+ g_clear_pointer(&priv->category, g_free); G_OBJECT_CLASS(gplugin_plugin_info_parent_class)->finalize(obj);
--- a/gplugin/gplugin-plugin-info.h Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-plugin-info.h Fri Mar 20 04:44:34 2020 +0000
@@ -33,14 +33,14 @@
#include <gplugin/gplugin-loader.h>
#include <gplugin/gplugin-version.h>
struct _GPluginPluginInfoClass {
- GInitiallyUnownedClass gparent;
--- a/gplugin/gplugin-private.h Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/gplugin-private.h Fri Mar 20 04:44:34 2020 +0000
@@ -14,19 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#if !defined(GPLUGIN_GLOBAL_HEADER_INSIDE) && !defined(GPLUGIN_COMPILATION)
-#error "only <gplugin.h> may be included directly"
#ifndef GPLUGIN_PRIVATE_H
#define GPLUGIN_PRIVATE_H
+/* this gets included by some tests so we need to trick the headers to accept +#define GPLUGIN_GLOBAL_HEADER_INSIDE #include <gplugin/gplugin-plugin-info.h>
#include <gplugin/gplugin-plugin.h>
+#undef GPLUGIN_GLOBAL_HEADER_INSIDE --- a/gplugin/meson.build Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/meson.build Fri Mar 20 04:44:34 2020 +0000
@@ -248,6 +248,7 @@
###############################################################################
###############################################################################
--- a/gplugin/tests/dynamic-type/dynamic-type-provider.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/tests/dynamic-type/dynamic-type-provider.c Fri Mar 20 04:44:34 2020 +0000
@@ -26,7 +26,6 @@
dynamic_test_init(G_GNUC_UNUSED DynamicTest *inst)
- g_message("instance created");
@@ -37,7 +36,6 @@
dynamic_test_class_init(G_GNUC_UNUSED DynamicTestClass *klass)
- g_message("class created");
G_MODULE_EXPORT GPluginPluginInfo *
--- a/gplugin/tests/test-core.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/tests/test-core.c Fri Mar 20 04:44:34 2020 +0000
@@ -20,6 +20,39 @@
/******************************************************************************
+ *****************************************************************************/ +test_gplugin_count_ids_and_plugins(gint *n_ids, gint *n_plugins) + GList *l_ids = NULL, *l_id = NULL; + gint ids = 0, plugins = 0; + l_ids = gplugin_manager_list_plugins(); + for(l_id = l_ids; l_id; l_id = l_id->next) { + GSList *l_plugins = NULL, *l_plugin = NULL; + const gchar *id = (const gchar *)l_id->data; + l_plugins = gplugin_manager_find_plugins(id); + for(l_plugin = l_plugins; l_plugin; l_plugin = l_plugin->next) { + g_slist_free_full(l_plugins, g_object_unref); +/****************************************************************************** *****************************************************************************/
@@ -57,8 +90,6 @@
test_gplugin_init_uninit_with_double_refresh_plugins(void)
gint f_ids = 0, s_ids = 0, f_plugins = 0, s_plugins = 0;
@@ -67,25 +98,11 @@
/* run the first refresh and count everything */
gplugin_manager_refresh();
- for(l = gplugin_manager_list_plugins(); l; l = l->next) {
- const gchar *id = (const gchar *)l->data;
- for(sl = gplugin_manager_find_plugins(id); sl; sl = sl->next)
+ test_gplugin_count_ids_and_plugins(&f_ids, &f_plugins); /* now run the second refresh and make sure the counts match */
gplugin_manager_refresh();
- for(l = gplugin_manager_list_plugins(); l; l = l->next) {
- const gchar *id = (const gchar *)l->data;
- for(sl = gplugin_manager_find_plugins(id); sl; sl = sl->next)
+ test_gplugin_count_ids_and_plugins(&s_ids, &s_plugins); g_assert_cmpint(f_ids, >, 0);
g_assert_cmpint(f_plugins, >, 0);
@@ -105,8 +122,6 @@
g_test_init(&argc, &argv, NULL);
g_test_add_func("/core/init_uninit", test_gplugin_init_uninit);
g_test_add_func("/core/init_init_uninit", test_gplugin_init_init_uninit);
--- a/gplugin/tests/test-loader-registration.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/tests/test-loader-registration.c Fri Mar 20 04:44:34 2020 +0000
@@ -17,10 +17,7 @@
-/* it's getting dirty in here... */
-#define GPLUGIN_COMPILATION
#include "../gplugin-private.h"
-#undef GPLUGIN_COMPILATION
@@ -95,7 +92,7 @@
*****************************************************************************/
-test_gplugin_manager_loader_register(void)
+test_gplugin_manager_loader_register_unregister(void) @@ -107,6 +104,11 @@
g_assert_no_error(error);
+ ret = gplugin_manager_unregister_loader(TEST_GPLUGIN_TYPE_LOADER, &error); + g_assert_no_error(error); @@ -125,21 +127,7 @@
ret = gplugin_manager_register_loader(TEST_GPLUGIN_TYPE_LOADER, &error);
g_assert_error(error, GPLUGIN_DOMAIN, 0);
-test_gplugin_manager_loader_unregister(void)
- gplugin_manager_private_uninit();
- gplugin_manager_private_init();
- ret = gplugin_manager_register_loader(TEST_GPLUGIN_TYPE_LOADER, &error);
- g_assert_no_error(error);
ret = gplugin_manager_unregister_loader(TEST_GPLUGIN_TYPE_LOADER, &error);
@@ -167,6 +155,7 @@
ret = gplugin_manager_unregister_loader(TEST_GPLUGIN_TYPE_LOADER, &error);
g_assert_error(error, GPLUGIN_DOMAIN, 0);
/******************************************************************************
@@ -175,24 +164,25 @@
main(gint argc, gchar **argv)
g_test_init(&argc, &argv, NULL);
- "/manager/loader/register",
- test_gplugin_manager_loader_register);
+ "/manager/loader/register_unregister", + test_gplugin_manager_loader_register_unregister); "/manager/loader/register-twice",
test_gplugin_manager_loader_register_twice);
- "/manager/loader/unregister",
- test_gplugin_manager_loader_unregister);
"/manager/loader/unregister-twice",
test_gplugin_manager_loader_unregister_twice);
--- a/gplugin/tests/test-native-loader.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/tests/test-native-loader.c Fri Mar 20 04:44:34 2020 +0000
@@ -49,6 +49,8 @@
/* now attempt to load the dependent plugin, it's supposed to fail */
g_assert_false(gplugin_manager_load_plugin(plugin, &error));
+ g_assert_error(error, GPLUGIN_DOMAIN, 0); /******************************************************************************
--- a/gplugin/tests/test-plugin-info.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/tests/test-plugin-info.c Fri Mar 20 04:44:34 2020 +0000
@@ -82,7 +82,6 @@
g_assert_cmpstr(tmp[i], ==, expected[i]);
/******************************************************************************
@@ -172,6 +171,8 @@
(TestStringVFunc)gplugin_plugin_info_get_dependencies,
+ g_object_unref(G_OBJECT(info)); @@ -282,6 +283,8 @@
(TestStringVFunc)gplugin_plugin_info_get_dependencies,
+ g_object_unref(G_OBJECT(info)); --- a/gplugin/tests/test-versioned-dependencies.c Mon Mar 09 03:03:39 2020 +0000
+++ b/gplugin/tests/test-versioned-dependencies.c Fri Mar 20 04:44:34 2020 +0000
@@ -15,44 +15,24 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#include <gplugin-native.h>
/******************************************************************************
*****************************************************************************/
-_test_plugin_load_and_has_dependent(
- GPluginPlugin *dependent,
- G_GNUC_UNUSED const gchar *id)
+_test_plugin_loaded(GPluginPlugin *dependent, const gchar *id) GPluginPlugin *plugin = NULL;
- GSList *deps = NULL, *l = NULL;
- gboolean found = FALSE;
- plugin = gplugin_manager_find_plugin("gplugin/test-no-version");
+ plugin = gplugin_manager_find_plugin(id); gplugin_plugin_get_state(plugin),
GPLUGIN_PLUGIN_STATE_LOADED);
- deps = gplugin_manager_get_plugin_dependencies(plugin, NULL);
- for(l = deps; l; l = l->next) {
- if(l->data == dependent) {
- g_slist_free_full(deps, g_object_unref);
g_object_unref(G_OBJECT(plugin));
@@ -64,8 +44,10 @@
GPluginPlugin *plugin = NULL;
- gplugin_manager_remove_paths();
gplugin_manager_append_path(TEST_VERSIONED_DEPENDENCY_DIR);
gplugin_manager_refresh();
@@ -73,26 +55,31 @@
g_assert_nonnull(plugin);
g_assert_true(GPLUGIN_IS_PLUGIN(plugin));
- gplugin_manager_load_plugin(plugin, &error);
+ ret = gplugin_manager_load_plugin(plugin, &error); g_assert_no_error(error);
gplugin_plugin_get_state(plugin),
GPLUGIN_PLUGIN_STATE_LOADED);
- g_object_unref(G_OBJECT(plugin));
/* now make sure each dependent plugin that's available was loaded */
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-no-version");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-exact1");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-exact2");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-greater");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-greater-equal");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-less");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-less-equal");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/bar");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/baz");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/fez");
+ _test_plugin_loaded(plugin, "gplugin/test-no-version"); + _test_plugin_loaded(plugin, "gplugin/test-exact1"); + _test_plugin_loaded(plugin, "gplugin/test-exact2"); + _test_plugin_loaded(plugin, "gplugin/test-greater"); + _test_plugin_loaded(plugin, "gplugin/test-greater-equal"); + _test_plugin_loaded(plugin, "gplugin/test-less"); + _test_plugin_loaded(plugin, "gplugin/test-less-equal"); + _test_plugin_loaded(plugin, "gplugin/bar"); + _test_plugin_loaded(plugin, "gplugin/baz"); + _test_plugin_loaded(plugin, "gplugin/fez"); + g_object_unref(G_OBJECT(plugin)); /******************************************************************************
@@ -101,11 +88,8 @@
main(gint argc, gchar **argv)
g_test_init(&argc, &argv, NULL);
/* test the load on query flag */
"/dependent-versions/super-dependent",
--- a/packaging/debian/libgplugin-dev.install Mon Mar 09 03:03:39 2020 +0000
+++ b/packaging/debian/libgplugin-dev.install Fri Mar 20 04:44:34 2020 +0000
@@ -3,6 +3,7 @@
debian/tmp/usr/include/gplugin-1.0/gplugin-native.h
debian/tmp/usr/lib/*/libgplugin.so
debian/tmp/usr/lib/*/pkgconfig/gplugin.pc
+debian/tmp/usr/share/gplugin/valgrind/gplugin.supp debian/tmp/usr/share/vala/vapi/gplugin.deps
debian/tmp/usr/share/vala/vapi/gplugin.vapi
--- a/packaging/gplugin.spec.in Mon Mar 09 03:03:39 2020 +0000
+++ b/packaging/gplugin.spec.in Fri Mar 20 04:44:34 2020 +0000
@@ -182,6 +182,7 @@
%doc HACKING.md README.md
%{_datadir}/gir-1.0/GPlugin-0.0.gir
%{_datadir}/gtk-doc/html/gplugin/
%{_includedir}/gplugin-1.0/