swapchain: fix management of tpl_display reference count 01/89101/3
authordeasung.kim <deasung.kim@samsung.com>
Thu, 22 Sep 2016 07:09:27 +0000 (16:09 +0900)
committerGwan-gyeong Mun <kk.moon@samsung.com>
Thu, 6 Oct 2016 06:58:31 +0000 (23:58 -0700)
increase reference count of tpl_display when the vulkan-wsi-tizen calls tpl_display_get()
it prevents segfault/abort when the vk_DestroySwapchainKHR is called.

Change-Id: I89e8162bbe63682e7617d1279b83b2af33fed942

src/wsi/swapchain.c
src/wsi/wsi.h

index f2e3626..8d5be33 100644 (file)
@@ -208,12 +208,12 @@ vk_DestroySwapchainKHR(VkDevice                                            device,
        tpl_surface_destroy_swapchain(chain->tpl_surface);
        free(chain->buffers);
 
-       if (chain->tpl_display)
-               tpl_object_unreference((tpl_object_t *)chain->tpl_display);
-
        if (chain->tpl_surface)
                tpl_object_unreference((tpl_object_t *)chain->tpl_surface);
 
+       if (chain->tpl_display)
+               tpl_object_unreference((tpl_object_t *)chain->tpl_display);
+
        vk_free(&chain->allocator, chain);
 }
 
index 4e52c39..9539a57 100644 (file)
@@ -89,8 +89,10 @@ static inline tpl_display_t *
 vk_get_tpl_display(tpl_handle_t native_dpy)
 {
        tpl_display_t *display = tpl_display_create(TPL_BACKEND_WAYLAND_VULKAN_WSI, native_dpy);
-       if (display == NULL)
+       if (display == NULL) {
                display = tpl_display_get(native_dpy);
+               tpl_object_reference((tpl_object_t *)display);
+       }
        return display;
 };