[gimp/wip/Jehan/make-check-CI-master: 4/4] app: do not free non-allocated DBus manager.



commit bb0afa290428ab1d499de4c37dc7a2c2d88b0acd
Author: Jehan <jehan girinstud io>
Date:   Thu Mar 19 11:19:18 2020 +0100

    app: do not free non-allocated DBus manager.
    
    While this issue was unseen so far on common desktop machines, the CI
    build encountered it, hence failing 6 of the unit tests.
    A connection to the bus could not be established hence the dbus_manager
    was never allocated, and finally it would crash at exit if we tried to
    unref it unconditionnally. Use g_clear_object() instead.
    
    Also add some stderr output for easier debugging, for when one of the 2
    possible error cases might happen (as documented by g_bus_own_name()).

 app/gui/gui-unique.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/app/gui/gui-unique.c b/app/gui/gui-unique.c
index 219cb341c6..1a5fede07f 100644
--- a/app/gui/gui-unique.c
+++ b/app/gui/gui-unique.c
@@ -409,6 +409,12 @@ gui_dbus_name_lost (GDBusConnection *connection,
                     const gchar     *name,
                     Gimp            *gimp)
 {
+  if (connection == NULL)
+    g_printerr ("%s: connection to the bus cannot be established.\n",
+                G_STRFUNC);
+  else
+    g_printerr ("%s: the name \"%s\" could not be acquired on the bus.\n",
+                G_STRFUNC, name);
 }
 
 static void
@@ -430,7 +436,7 @@ static void
 gui_dbus_service_exit (void)
 {
   g_bus_unown_name (dbus_name_id);
-  g_object_unref (dbus_manager);
+  g_clear_object (&dbus_manager);
 }
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]