[dconf: 2/5] gdbus/thread: Always ref GDBusConnection on getters



commit f992a5c2a61d2beadb0e84dd42f3e917c0567981
Author: Andre Moreira Magalhaes <andre endlessm com>
Date:   Tue Jul 23 20:11:14 2019 +0000

    gdbus/thread: Always ref GDBusConnection on getters
    
    This change should guarantee that the object is valid while in use.
    
    The change is part of a series of changes to fix an issue
    introduced with recent changes made to GLib[1] where invoking
    g_test_dbus_down() will fail after a timeout if the GDBusConnection
    object for the session bus leaks.
    
    [1] https://gitlab.gnome.org/GNOME/glib/merge_requests/963
    
    Signed-off-by: Andre Moreira Magalhaes <andre endlessm com>

 gdbus/dconf-gdbus-thread.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/gdbus/dconf-gdbus-thread.c b/gdbus/dconf-gdbus-thread.c
index 8b8f048..34c875b 100644
--- a/gdbus/dconf-gdbus-thread.c
+++ b/gdbus/dconf-gdbus-thread.c
@@ -187,7 +187,7 @@ dconf_gdbus_get_bus_common (GBusType       bus_type,
       return NULL;
     }
 
-  return dconf_gdbus_get_bus_data[bus_type];
+  return g_object_ref (dconf_gdbus_get_bus_data[bus_type]);
 }
 
 static GDBusConnection *
@@ -260,7 +260,7 @@ static gboolean
 dconf_gdbus_method_call (gpointer user_data)
 {
   DConfGDBusCall *call = user_data;
-  GDBusConnection *connection;
+  g_autoptr(GDBusConnection) connection = NULL;
   const GError *error = NULL;
 
   connection = dconf_gdbus_get_bus_in_worker (call->bus_type, &error);
@@ -315,8 +315,9 @@ static gboolean
 dconf_gdbus_summon_bus (gpointer user_data)
 {
   GBusType bus_type = GPOINTER_TO_INT (user_data);
+  g_autoptr(GDBusConnection) connection = NULL;
 
-  dconf_gdbus_get_bus_in_worker (bus_type, NULL);
+  connection = dconf_gdbus_get_bus_in_worker (bus_type, NULL);
 
   return G_SOURCE_REMOVE;
 }
@@ -359,7 +360,7 @@ dconf_engine_dbus_call_sync_func (GBusType             bus_type,
                                   GError             **error)
 {
   const GError *inner_error = NULL;
-  GDBusConnection *connection;
+  g_autoptr(GDBusConnection) connection = NULL;
 
   connection = dconf_gdbus_get_bus_for_sync (bus_type, &inner_error);
 


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