[glib/1525-task-result: 1/4] tests: Fix location of an unref in the GTask tests



commit 03232bd6a60a6f8436755be862c2aca2f2e72bdb
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Oct 1 21:44:01 2018 +0100

    tests: Fix location of an unref in the GTask tests
    
    This method drops the last reference *it* owns to the GTask, but then
    continues to call methods on the GTask. This wasn’t resulting in
    failures because a ref in another thread kept the GTask alive, but
    that’s quite dodgy.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gio/tests/task.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gio/tests/task.c b/gio/tests/task.c
index 934262e40..c66aa29a3 100644
--- a/gio/tests/task.c
+++ b/gio/tests/task.c
@@ -1689,7 +1689,6 @@ test_return_on_cancel_atomic (void)
 
   g_task_set_task_data (task, (gpointer)&state, NULL);
   g_task_run_in_thread (task, return_on_cancel_atomic_thread);
-  g_object_unref (task);
 
   g_assert_cmpint (state, ==, 0);
 
@@ -1724,6 +1723,7 @@ test_return_on_cancel_atomic (void)
   g_object_unref (cancellable);
   g_mutex_unlock (&roca_mutex_1);
   g_mutex_unlock (&roca_mutex_2);
+  g_object_unref (task);
 }
 
 /* test_return_pointer: memory management of pointer returns */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]