gobject/tests: Don't unref a floating object reference by mistake

This goes undiagnosed under normal circumstances, but is a critical
warning (which is fatal by default) under G_ENABLE_DIAGNOSTIC. This is a
programming error, so we should only exercise it under
g_test_undefined(), and only in a test that is intentionally doing this
(as in the previous commit).

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2022-09-21 11:03:44 +01:00
parent 0bba27eea9
commit 7254fd7aa3

View File

@ -185,7 +185,7 @@ test_interface_check (void)
check_called = 0;
g_type_add_interface_check (&check_called, check_func);
o = g_object_new (bazo_get_type (), NULL);
o = g_object_ref_sink (g_object_new (bazo_get_type (), NULL));
g_object_unref (o);
g_assert_cmpint (check_called, ==, 1);
g_type_remove_interface_check (&check_called, check_func);