Do not send CLIPBOARD_EMPTY when paste error case 40/314740/2
authorJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 18 Jul 2024 08:20:07 +0000 (17:20 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 18 Jul 2024 08:21:34 +0000 (17:21 +0900)
Change-Id: I85ff1a80baf43734cf78de3cdda5a7a51f01a208
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/cbhm.c

index 46a5c8a..be0ceb1 100644 (file)
@@ -214,11 +214,11 @@ _data_source_send(void *data, struct wl_data_source *source, const char *mime_ty
        cbhm_data_offer = info->cbhm_data_offer;
 
        if (info->data_source != source) {
-               WRN("[CBHM]_data_source_send: source changed\n");
-               buf = strdup("CLIPBOARD_EMPTY");
+               WRN("[CBHM]_data_source_send: source changed (current:%p, request:%p)\n", info->data_source, source);
+               goto done;
        } else if (LIST_IS_EMPTY(&info->received_data_list)) {
                WRN("[CBHM]_data_source_send: no saved data\n");
-               buf = strdup("CLIPBOARD_EMPTY");
+               goto done;
        } else {
                LIST_FOR_EACH_ENTRY(received_data, &info->received_data_list, item_link) {
                        if (!strcmp(received_data->mimetype, mime_type)) {
@@ -231,7 +231,7 @@ _data_source_send(void *data, struct wl_data_source *source, const char *mime_ty
 
        if (!buf) {
                WRN("[CBHM]_data_source_send: type mismatch (%s)\n", mime_type);
-               buf = strdup("CLIPBOARD_EMPTY");
+               goto done;
        }
 
        size_ret = strlen(buf) + 1;
@@ -239,7 +239,7 @@ _data_source_send(void *data, struct wl_data_source *source, const char *mime_ty
        if (size_ret <= 1) {
                ERR("[CBHM]_data_source_send: size_ret is not correct\n");
                free(buf);
-               return;
+               goto done;
        }
 
        cur_buf = buf;
@@ -277,7 +277,7 @@ _data_source_send(void *data, struct wl_data_source *source, const char *mime_ty
        cur_buf = NULL;
        free(buf);
        buf = NULL;
-
+done:
        close(fd);
 }
 
@@ -352,6 +352,7 @@ _cbhm_set_selection(Cbhm_Glib_Info *info)
                ERR("[CBHM]_cbhm_set_selection: wl_data_device_manager_create_data_source fail\n");
                return;
        }
+       INF("[CBHM]_cbhm_set_selection create source(%p)\n", info->data_source);
 
        LIST_FOR_EACH_ENTRY(mime, &cbhm_data_offer->offer_mimetype_list, item_link) {
                t = wl_array_add(&info->types, sizeof(*t));
@@ -376,7 +377,7 @@ _cbhm_offer_receive(Cbhm_Glib_Info *info)
        cbhm_data_offer = info->cbhm_data_offer;
 
        if (info->data_received_count == cbhm_data_offer->type_count) {
-               INF("[CBHM]_cbhm_offer_receive: already received all type data : %d", cbhm_data_offer->type_count);
+               INF("[CBHM]_cbhm_offer_receive: already received all type data : %d\n", cbhm_data_offer->type_count);
                return;
        }
 
@@ -388,7 +389,7 @@ _cbhm_offer_receive(Cbhm_Glib_Info *info)
                info->temp_mime_type = strdup(mime->mimetype);
                break;
        }
-       INF("[CBHM]_cbhm_offer_receive: selected mime type : %s", info->temp_mime_type);
+       INF("[CBHM]_cbhm_offer_receive: selected mime type : %s\n", info->temp_mime_type);
 
        if (pipe2(pipe, O_CLOEXEC) == -1) {
                ERR("[CBHM]_cbhm_offer_receive: pipe2 fail\n");