diff options
author | Christian Hergert <chergert@redhat.com> | 2023-03-17 14:15:15 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2023-03-22 16:44:35 -0700 |
commit | c40bf394e6fd1cc7c077e79a2a8ba97cf3a1c608 (patch) | |
tree | 5f475c518828f4a9cf61b42613524e2329328e9f | |
parent | a56d7ed643ab481a2df29842141909e6a81ae92c (diff) | |
download | libpeas-c40bf394e6fd1cc7c077e79a2a8ba97cf3a1c608.tar.gz |
tests: ensure builtin plugin releases object
And fix the tests so that ASAN doesn't complain about leaks.
-rw-r--r-- | tests/libpeas/extension-set.c | 9 | ||||
-rw-r--r-- | tests/plugins/builtin/builtin-plugin.c | 12 |
2 files changed, 19 insertions, 2 deletions
diff --git a/tests/libpeas/extension-set.c b/tests/libpeas/extension-set.c index 313da01..93ec32d 100644 --- a/tests/libpeas/extension-set.c +++ b/tests/libpeas/extension-set.c @@ -155,6 +155,7 @@ valid_extension_added_cb (PeasExtensionSet *extension_set, PeasExtension *extension, GObject **obj_ptr) { + g_clear_object (obj_ptr); g_object_get (PEAS_ACTIVATABLE (extension), "object", obj_ptr, NULL); } @@ -164,7 +165,8 @@ test_extension_set_create_valid_with_properties (PeasEngine *engine) PeasPluginInfo *info; PeasExtensionSet *extension_set; GValue prop_value = G_VALUE_INIT; - GObject *obj, *obj_cmp; + GObject *obj; + GObject *obj_cmp = NULL; const gchar *prop_names[1] = { "object" }; obj = g_object_new (G_TYPE_OBJECT, NULL); @@ -186,8 +188,11 @@ test_extension_set_create_valid_with_properties (PeasEngine *engine) g_assert (obj == obj_cmp); g_assert (PEAS_IS_EXTENSION_SET (extension_set)); - g_object_unref (extension_set); + g_assert_finalize_object (extension_set); g_value_unset (&prop_value); + + g_object_unref (obj_cmp); + g_assert_finalize_object (obj); } diff --git a/tests/plugins/builtin/builtin-plugin.c b/tests/plugins/builtin/builtin-plugin.c index 9533433..f191068 100644 --- a/tests/plugins/builtin/builtin-plugin.c +++ b/tests/plugins/builtin/builtin-plugin.c @@ -113,12 +113,24 @@ testing_builtin_plugin_deactivate (PeasActivatable *activatable) } static void +builtin_plugin_dispose (GObject *object) +{ + TestingBuiltinPlugin *plugin = TESTING_BUILTIN_PLUGIN (object); + TestingBuiltinPluginPrivate *priv = GET_PRIV (plugin); + + g_clear_object (&priv->object); + + G_OBJECT_CLASS (testing_builtin_plugin_parent_class)->dispose (object); +} + +static void testing_builtin_plugin_class_init (TestingBuiltinPluginClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->set_property = testing_builtin_plugin_set_property; object_class->get_property = testing_builtin_plugin_get_property; + object_class->dispose = builtin_plugin_dispose; g_object_class_override_property (object_class, PROP_OBJECT, "object"); } |