mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-13 22:07:15 +01:00
Merge branch 'th/test-weak-notify' into 'main'
[th/test-weak-notify] gobject/tests: add test checking that GWeakRef is cleared in GWeakNotify See merge request GNOME/glib!3865
This commit is contained in:
commit
5f855022a6
@ -105,6 +105,17 @@ weak_ref2 (gpointer data,
|
|||||||
weak_ref2_notified = TRUE;
|
weak_ref2_notified = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
weak_ref3 (gpointer data,
|
||||||
|
GObject *object)
|
||||||
|
{
|
||||||
|
GWeakRef *weak_ref = data;
|
||||||
|
|
||||||
|
g_assert_null (g_weak_ref_get (weak_ref));
|
||||||
|
|
||||||
|
weak_ref2_notified = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toggle_ref1 (gpointer data,
|
toggle_ref1 (gpointer data,
|
||||||
GObject *object,
|
GObject *object,
|
||||||
@ -154,6 +165,7 @@ static void
|
|||||||
test_references (void)
|
test_references (void)
|
||||||
{
|
{
|
||||||
GObject *object;
|
GObject *object;
|
||||||
|
GWeakRef weak_ref;
|
||||||
|
|
||||||
/* Test basic weak reference operation */
|
/* Test basic weak reference operation */
|
||||||
global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
|
global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
|
||||||
@ -191,6 +203,17 @@ test_references (void)
|
|||||||
g_assert_true (weak_ref2_notified);
|
g_assert_true (weak_ref2_notified);
|
||||||
g_assert_true (object_destroyed);
|
g_assert_true (object_destroyed);
|
||||||
|
|
||||||
|
/* Test that within a GWeakNotify the GWeakRef is NULL already. */
|
||||||
|
weak_ref2_notified = FALSE;
|
||||||
|
object = g_object_new (G_TYPE_OBJECT, NULL);
|
||||||
|
g_weak_ref_init (&weak_ref, object);
|
||||||
|
g_assert_true (object == g_weak_ref_get (&weak_ref));
|
||||||
|
g_object_weak_ref (object, weak_ref3, &weak_ref);
|
||||||
|
g_object_unref (object);
|
||||||
|
g_object_unref (object);
|
||||||
|
g_assert_true (weak_ref2_notified);
|
||||||
|
g_weak_ref_clear (&weak_ref);
|
||||||
|
|
||||||
/* Test basic toggle reference operation */
|
/* Test basic toggle reference operation */
|
||||||
global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
|
global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user