From 7dfe9d051ec17276e10a6f935b45c7c0d63f1770 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 29 Sep 2022 21:04:56 +0900 Subject: [PATCH] Delete wrong g_main_context_unref - 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 --- src/tpl_utils_gthread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 20bab7f..f1dab0c 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -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; -- 2.7.4