tpl_wl_egl_thread: Added some exception checking. 32/147432/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Mon, 4 Sep 2017 09:17:04 +0000 (18:17 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Mon, 4 Sep 2017 09:27:55 +0000 (18:27 +0900)
Change-Id: I8c4ef999cbd0c8a537cfa2a6cf2f07d877a004ab
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index 4c2e8a6..eacb73c 100644 (file)
@@ -57,26 +57,22 @@ __tpl_wl_egl_display_init(tpl_display_t *display)
        display->bufmgr_fd = -1;
 
        if (twe_check_native_handle_is_wl_display(display->native_handle)) {
-               twe_thread *wl_egl_thread = NULL;
-               twe_display_h twe_display = NULL;
-
-               wl_egl_thread = twe_thread_create();
-               if (!wl_egl_thread) {
+               wayland_egl_display->wl_egl_thread = twe_thread_create();
+               if (!wayland_egl_display->wl_egl_thread) {
                        TPL_ERR("Failed to create twe_thread.");
                        goto free_display;
                }
 
-               twe_display = twe_display_add(wl_egl_thread, display->native_handle);
-               if (!twe_display) {
+               wayland_egl_display->twe_display =
+                       twe_display_add(wayland_egl_display->wl_egl_thread,
+                                                       display->native_handle);
+               if (!wayland_egl_display->twe_display) {
                        TPL_ERR("Failed to add native_display(%p) to thread(%p)",
-                                       display->native_handle, wl_egl_thread);
-                       twe_thread_destroy(wl_egl_thread);
+                                       display->native_handle,
+                                       wayland_egl_display->wl_egl_thread);
                        goto free_display;
                }
 
-               wayland_egl_display->wl_egl_thread = wl_egl_thread;
-               wayland_egl_display->twe_display = twe_display;
-
        } else {
                TPL_ERR("Invalid native handle for display.");
                goto free_display;
@@ -91,6 +87,10 @@ __tpl_wl_egl_display_init(tpl_display_t *display)
        return TPL_ERROR_NONE;
 
 free_display:
+       if (wayland_egl_display->twe_display)
+               twe_display_del(wayland_egl_display->twe_display);
+       if (wayland_egl_display->wl_egl_thread)
+               twe_thread_destroy(wayland_egl_display->wl_egl_thread);
        wayland_egl_display->wl_egl_thread = NULL;
        wayland_egl_display->twe_display = NULL;