mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
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
This commit is contained in:
commit
4e538e674c
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user