diff options
author | Andre Moreira Magalhaes <andre@endlessm.com> | 2019-07-23 20:11:14 +0000 |
---|---|---|
committer | Andre Moreira Magalhaes <andre@endlessm.com> | 2019-07-24 21:37:22 +0000 |
commit | f992a5c2a61d2beadb0e84dd42f3e917c0567981 (patch) | |
tree | 61549f3f3196e0f676e7f88619b40de3a95ce323 /gdbus | |
parent | 9a3ba4ed5c655cddcff0db15799600dcfa0431ba (diff) | |
download | dconf-f992a5c2a61d2beadb0e84dd42f3e917c0567981.tar.gz |
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>
Diffstat (limited to 'gdbus')
-rw-r--r-- | gdbus/dconf-gdbus-thread.c | 9 |
1 files 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); |