diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2019-07-05 11:52:28 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2019-07-05 11:52:28 +0000 |
commit | 4e538e674cfdbeec7510d1bdab3e62c4e38ca359 (patch) | |
tree | a381de787622b25fd5e6fdd862946419efeae2f0 | |
parent | 711b4b05781a4459962375ac14be26164e7adfd3 (diff) | |
parent | d4db5a828883a040be00dd0f80400132220a1b72 (diff) | |
download | glib-4e538e674cfdbeec7510d1bdab3e62c4e38ca359.tar.gz |
Merge branch 'bug-787-investigation' into 'master'
Fix memory error with GDBusConnection in g_test_dbus_down()
Closes #787
See merge request GNOME/glib!963
-rw-r--r-- | gio/gtestdbus.c | 14 | ||||
-rw-r--r-- | gio/tests/gdbus-connection-loss.c | 3 | ||||
-rw-r--r-- | gio/tests/gdbus-names.c | 3 |
3 files changed, 9 insertions, 11 deletions
diff --git a/gio/gtestdbus.c b/gio/gtestdbus.c index 99c9cf8ea..11cf029d9 100644 --- a/gio/gtestdbus.c +++ b/gio/gtestdbus.c @@ -67,15 +67,14 @@ on_weak_notify_timeout (gpointer user_data) } static gboolean -dispose_on_idle (gpointer object) +unref_on_idle (gpointer object) { - g_object_run_dispose (object); g_object_unref (object); return FALSE; } static gboolean -_g_object_dispose_and_wait_weak_notify (gpointer object) +_g_object_unref_and_wait_weak_notify (gpointer object) { WeakNotifyData data; guint timeout_id; @@ -85,9 +84,10 @@ _g_object_dispose_and_wait_weak_notify (gpointer object) g_object_weak_ref (object, (GWeakNotify) g_main_loop_quit, data.loop); - /* Drop the ref in an idle callback, this is to make sure the mainloop - * is already running when weak notify happens */ - g_idle_add (dispose_on_idle, object); + /* Drop the strong ref held by the caller in an idle callback. This is to + * make sure the mainloop is already running when weak notify happens (when + * all other strong ref holders have dropped theirs). */ + g_idle_add (unref_on_idle, object); /* Make sure we don't block forever */ timeout_id = g_timeout_add (30 * 1000, on_weak_notify_timeout, &data); @@ -820,7 +820,7 @@ g_test_dbus_down (GTestDBus *self) stop_daemon (self); if (connection != NULL) - _g_object_dispose_and_wait_weak_notify (connection); + _g_object_unref_and_wait_weak_notify (connection); g_test_dbus_unset (); _g_bus_forget_singleton (G_BUS_TYPE_SESSION); diff --git a/gio/tests/gdbus-connection-loss.c b/gio/tests/gdbus-connection-loss.c index 9dbbeb2a4..8f7023f3f 100644 --- a/gio/tests/gdbus-connection-loss.c +++ b/gio/tests/gdbus-connection-loss.c @@ -136,9 +136,10 @@ main (int argc, ret = g_test_run(); + g_object_unref (c); + session_bus_down (); - g_object_unref (c); g_main_loop_unref (loop); return ret; diff --git a/gio/tests/gdbus-names.c b/gio/tests/gdbus-names.c index 648b54774..4f95b457a 100644 --- a/gio/tests/gdbus-names.c +++ b/gio/tests/gdbus-names.c @@ -472,9 +472,6 @@ test_bus_own_name (void) g_object_unref (c2); session_bus_down (); - - /* See https://bugzilla.gnome.org/show_bug.cgi?id=711807 */ - g_usleep (1000000); } /* ---------------------------------------------------------------------------------------------------- */ |