[dconf: 3/5] gdbus/thread: Always copy GError on getters



commit 6fbf07188542806f126bbee4f15bd0eb95057843
Author: Andre Moreira Magalhaes <andre endlessm com>
Date:   Tue Jul 23 17:17:50 2019 +0000

    gdbus/thread: Always copy GError 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 | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/gdbus/dconf-gdbus-thread.c b/gdbus/dconf-gdbus-thread.c
index 34c875b..a8985cd 100644
--- a/gdbus/dconf-gdbus-thread.c
+++ b/gdbus/dconf-gdbus-thread.c
@@ -176,13 +176,13 @@ static gpointer dconf_gdbus_get_bus_data[5];
 static gboolean dconf_gdbus_get_bus_is_error[5];
 
 static GDBusConnection *
-dconf_gdbus_get_bus_common (GBusType       bus_type,
-                            const GError **error)
+dconf_gdbus_get_bus_common (GBusType   bus_type,
+                            GError   **error)
 {
   if (dconf_gdbus_get_bus_is_error[bus_type])
     {
       if (error)
-        *error = dconf_gdbus_get_bus_data[bus_type];
+        *error = g_error_copy (dconf_gdbus_get_bus_data[bus_type]);
 
       return NULL;
     }
@@ -191,8 +191,8 @@ dconf_gdbus_get_bus_common (GBusType       bus_type,
 }
 
 static GDBusConnection *
-dconf_gdbus_get_bus_in_worker (GBusType       bus_type,
-                               const GError **error)
+dconf_gdbus_get_bus_in_worker (GBusType   bus_type,
+                               GError   **error)
 {
   g_assert_cmpint (bus_type, <, G_N_ELEMENTS (dconf_gdbus_get_bus_data));
 
@@ -261,7 +261,7 @@ dconf_gdbus_method_call (gpointer user_data)
 {
   DConfGDBusCall *call = user_data;
   g_autoptr(GDBusConnection) connection = NULL;
-  const GError *error = NULL;
+  g_autoptr(GError) error = NULL;
 
   connection = dconf_gdbus_get_bus_in_worker (call->bus_type, &error);
 
@@ -323,8 +323,8 @@ dconf_gdbus_summon_bus (gpointer user_data)
 }
 
 static GDBusConnection *
-dconf_gdbus_get_bus_for_sync (GBusType       bus_type,
-                              const GError **error)
+dconf_gdbus_get_bus_for_sync (GBusType   bus_type,
+                              GError   **error)
 {
   g_assert_cmpint (bus_type, <, G_N_ELEMENTS (dconf_gdbus_get_bus_data));
 
@@ -359,18 +359,14 @@ dconf_engine_dbus_call_sync_func (GBusType             bus_type,
                                   const GVariantType  *reply_type,
                                   GError             **error)
 {
-  const GError *inner_error = NULL;
   g_autoptr(GDBusConnection) connection = NULL;
 
-  connection = dconf_gdbus_get_bus_for_sync (bus_type, &inner_error);
+  connection = dconf_gdbus_get_bus_for_sync (bus_type, error);
 
   if (connection == NULL)
     {
       g_variant_unref (g_variant_ref_sink (parameters));
 
-      if (error)
-        *error = g_error_copy (inner_error);
-
       return NULL;
     }
 


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