From 3763bb47a4fd74240980a54025ba61e7cbd5c3a5 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 4 Sep 2017 16:44:17 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Modified the destroy process of disp_source. - Changed the last unref of gsource to be executed in the main thread. Change-Id: Ifbcfe438f2aed8f82662eb675576d5dc3792e674 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index d0f9bb2..e95bb04 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -409,24 +409,7 @@ _twe_thread_wl_disp_finalize(GSource *source) { twe_wl_disp_source *disp_source = (twe_wl_disp_source *)source; - TPL_OBJECT_LOCK(&disp_source->obj); - - /* If disp_source is in prepared state, cancel it */ - if (disp_source->prepared) { - wl_display_cancel_read(disp_source->disp); - disp_source->prepared = TPL_FALSE; - } - - if (wl_display_dispatch_queue_pending(disp_source->disp, - disp_source->ev_queue) == -1) { - _twe_display_print_err(disp_source, "dispatch_queue_pending"); - } - - TPL_LOG_T("WL_EGL", "finalize| wl_event_queue(%p)", - disp_source->ev_queue); - - wl_event_queue_destroy(disp_source->ev_queue); - TPL_OBJECT_UNLOCK(&disp_source->obj); + TPL_LOG_T("WL_EGL", "finalize| disp_source(%p)", disp_source); __tpl_object_fini(&disp_source->obj); @@ -574,9 +557,24 @@ _twe_thread_wl_disp_del(twe_wl_disp_source *disp_source) return; } + TPL_OBJECT_LOCK(&disp_source->obj); + + /* If disp_source is in prepared state, cancel it */ + if (disp_source->prepared) { + wl_display_cancel_read(disp_source->disp); + disp_source->prepared = TPL_FALSE; + } + + if (wl_display_dispatch_queue_pending(disp_source->disp, + disp_source->ev_queue) == -1) { + _twe_display_print_err(disp_source, "dispatch_queue_pending"); + } + + wl_event_queue_destroy(disp_source->ev_queue); + TPL_OBJECT_UNLOCK(&disp_source->obj); + g_source_remove_poll(&disp_source->gsource, &disp_source->gfd); g_source_destroy(&disp_source->gsource); - g_source_unref(&disp_source->gsource); TPL_LOG_T("WL_EGL", "[DEL] twe_display(%p) wl_display(%p)", disp_source, disp_source->disp); @@ -734,7 +732,6 @@ twe_display_add(twe_thread* thread, struct wl_display *display) g_source_set_callback(&source->gsource, NULL, display, NULL); g_source_add_poll(&source->gsource, &source->gfd); g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop)); - g_source_unref(&source->gsource); TPL_LOG_T("WL_EGL", "add| gsource(%p) ev_queue(%p) wl_display(%p)", source, source->ev_queue, display); @@ -768,6 +765,8 @@ twe_display_del(twe_display_h twe_display) /* Waiting for destroying disp_source */ } + g_source_unref(&source->gsource); + _twe_display_del_source_fini(disp_del_source); return TPL_ERROR_NONE; -- 2.7.4