Delete wrong g_main_context_unref 04/282304/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Thu, 29 Sep 2022 12:04:56 +0000 (21:04 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Thu, 29 Sep 2022 12:04:58 +0000 (21:04 +0900)
 - GMainContext is also destroyed when GMainLoop is destroyed.
  Therefore, it is the wrong code to do context_unref before loop_unref.

Change-Id: Ib57eab7ba4345565977102abb0df3268d7f42acb
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_utils_gthread.c

index 20bab7f..f1dab0c 100644 (file)
@@ -70,12 +70,14 @@ tpl_gthread_create(const char *thread_name,
                return NULL;
        }
 
+       // context's ref count was increased in g_main_loop_new
        g_main_context_unref(context);
 
        new_thread = calloc(1, sizeof(tpl_gthread));
        if (!new_thread) {
                TPL_ERR("Failed to allocate tpl_gthread");
-               g_main_context_unref(context);
+
+               // context is also destroyed when loop is destroyed.
                g_main_loop_unref(loop);
 
                return NULL;