gplugin/gplugin

Use g_set_object to make the code a bit easier to read.
feature/find-newest-plugin
2020-04-18, Gary Kramlich
cf0e98444d64
Parents 340ac4280635
Children 8db39318cdac
Use g_set_object to make the code a bit easier to read.
--- a/gplugin/gplugin-manager.c Sat Apr 18 02:46:24 2020 -0500
+++ b/gplugin/gplugin-manager.c Sat Apr 18 03:48:25 2020 -0500
@@ -1796,21 +1796,18 @@
cmp = gplugin_version_compare(version_a, version_b);
if(cmp < 0) {
- /* plugin_b has a newer version */
-
- /* unref the old objects */
- g_clear_object(&plugin_a);
- g_clear_object(&info_a);
+ /* plugin_b has a newer version, so set the plugin_a pointers to
+ * the plugin_b pointers as well as the version pointers.
+ */
+ g_set_object(&plugin_a, plugin_b);
+ g_set_object(&info_a, info_b);
- /* now point the pointers to the plugin_b pointers */
- plugin_a = plugin_b;
- info_a = info_b;
version_a = version_b;
- } else {
- /* plugin_b has an older or equal to version so we keep plugin_a */
- g_clear_object(&plugin_b);
- g_clear_object(&info_b);
}
+
+ /* Clean up the plugin_b pointers. */
+ g_clear_object(&plugin_b);
+ g_clear_object(&info_b);
}
g_clear_object(&info_a);