Index: dialogs/dlg_lib_pstk.c =================================================================== --- dialogs/dlg_lib_pstk.c (revision 37002) +++ dialogs/dlg_lib_pstk.c (revision 37003) @@ -509,12 +509,13 @@ fclose(f); if (res == 0) { long size = rnd_file_size(&ctx->pcb->hidlib, tmp_fn); - void *buf; - if ((size > 0) && ((buf = malloc(size)) != NULL)) { + char *buf; + if ((size > 0) && ((buf = malloc(size+1)) != NULL)) { f = rnd_fopen(&ctx->pcb->hidlib, tmp_fn, "r"); if (f != NULL) { if (fread(buf, size, 1, f) == 1) { - if (rnd_gui->clip_set(rnd_gui, RND_HID_CLIPFMT_TEXT, buf, size) != 0) + buf[size] = '\0'; + if (rnd_gui->clip_set(rnd_gui, buf) != 0) rnd_message(RND_MSG_ERROR, "Failed to write the clipboard\n"); } else @@ -539,13 +540,10 @@ pcb_data_t *data = get_data(ctx, ctx->subc_id, NULL); rnd_hid_row_t *row = rnd_dad_tree_get_selected(&ctx->dlg[ctx->wlist]); pcb_pstk_proto_t *proto; - char *tmp_fn; - void *buf; + char *tmp_fn, *buf; FILE *f; rnd_hid_attr_val_t hv; - size_t size; - int res, res2; - rnd_hid_clipfmt_t fmt; + int res2; if (data == NULL) return; @@ -571,28 +569,18 @@ return; } - res = rnd_gui->clip_get(rnd_gui, &fmt, &buf, &size); - if (res == 0) { - res2 = fwrite(buf, size, 1, f); - rnd_gui->clip_free(rnd_gui, fmt, buf, size); + buf = rnd_gui->clip_get(rnd_gui); + if (buf != NULL) { + res2 = fwrite(buf, strlen(buf), 1, f); + free(buf); } fclose(f); - if (res != 0) { - rnd_message(RND_MSG_ERROR, "Failed to get data from the clipboard\n"); - rnd_tempfile_unlink(tmp_fn); - return; - } if (res2 != 1) { rnd_message(RND_MSG_ERROR, "Failed to write data in temporary file %s\n", tmp_fn); rnd_tempfile_unlink(tmp_fn); return; } - if (fmt != RND_HID_CLIPFMT_TEXT) { - rnd_message(RND_MSG_ERROR, "Invalid clipboard format\n"); - rnd_tempfile_unlink(tmp_fn); - return; - } if (pcb_load_padstack(&ctx->pcb->hidlib, proto, tmp_fn, NULL) != 0) rnd_message(RND_MSG_ERROR, "Padstack failed to import from the clipboard.\n"); Index: dialogs/dlg_view.c =================================================================== --- dialogs/dlg_view.c (revision 37002) +++ dialogs/dlg_view.c (revision 37003) @@ -382,7 +382,7 @@ } } pcb_view_save_list_end(&tmp, NULL); - rnd_gui->clip_set(rnd_gui, RND_HID_CLIPFMT_TEXT, tmp.array, tmp.used+1); + rnd_gui->clip_set(rnd_gui, tmp.array); gds_uninit(&tmp); if (cut) view2dlg_list(ctx); @@ -391,8 +391,8 @@ static void view_paste_btn_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr_btn) { view_ctx_t *ctx = caller_data; - rnd_hid_clipfmt_t cformat; - void *cdata, *load_ctx; + char *cdata; + void *load_ctx; size_t clen; pcb_view_t *v, *vt = NULL; rnd_hid_attribute_t *attr = &ctx->dlg[ctx->wlist]; @@ -408,16 +408,12 @@ vt = pcb_view_by_uid(ctx->lst, r->user_data2.lng); } - if (rnd_gui->clip_get(rnd_gui, &cformat, &cdata, &clen) != 0) + cdata = rnd_gui->clip_get(rnd_gui); + if (cdata == NULL) return; - if (cformat != RND_HID_CLIPFMT_TEXT) { - rnd_gui->clip_free(rnd_gui, cformat, cdata, clen); - return; - } - load_ctx = pcb_view_load_start_str(cdata); - rnd_gui->clip_free(rnd_gui, cformat, cdata, clen); + free(cdata); if (load_ctx == NULL) return;