Fix tbm_surface memory leak 62/154462/3
authorJunghoon Park <jh9216.park@samsung.com>
Tue, 10 Oct 2017 08:46:45 +0000 (17:46 +0900)
committerSemun Lee <semun.lee@samsung.com>
Wed, 18 Oct 2017 07:51:21 +0000 (07:51 +0000)
- When changed buff event comes in bind mode, it needs to unref tbm_surface from updated wl_buffer

Change-Id: Id6d42e0aeb76f858d5a7cc5fb3c03d736d549c97
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c

index 29e4552..ab2b953 100644 (file)
@@ -968,9 +968,20 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type,
        if (toolkit_evas_h->blocked || toolkit_evas_h->bind_win_id > 0) {
                if (tizen_remote_surface_get_version(trs)
                                >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION) {
-                       tizen_remote_surface_release(trs, tbm);
-                       g_hash_table_remove(__cur_buffer_table, tbm);
+                       if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) {
+                               if (g_hash_table_lookup(__cur_buffer_table, tbm) == NULL) {
+                                       tbm_surface = wl_buffer_get_user_data(tbm);
+                                       if (tbm_surface) {
+                                               LOGE("Skip update cb filter[%d] bind[%d]",
+                                                               toolkit_evas_h->blocked, toolkit_evas_h->bind_win_id);
+                                               tbm_surface_internal_unref(tbm_surface);
+                                       }
+                                       tizen_remote_surface_release(trs, tbm);
+                                       wl_buffer_destroy(tbm);
+                               }
+                       }
                }
+
                close(img_file_fd); /* close passed fd */
                return;
        }