From 132d335757335e1cb5dcb2ead699cd0d173f960a Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 7 Mar 2024 18:32:42 +0100 Subject: [PATCH] fix a regression in merge_file(0,...) from user provided file being aborted --- src/callback.c | 2 +- src/move.c | 1 + src/paste.c | 10 +++++++--- src/xschem.h | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/callback.c b/src/callback.c index ae9199dc..7d6f84e1 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1867,7 +1867,7 @@ int rstate; /* (reduced state, without ShiftMask) */ unselect_all(1); } /* xschem window *receiving* selected objects selection cleared --> abort */ - else if(!xctx->paste_from && stat(sel_file, &buf) && (xctx->ui_state & STARTMERGE)) { + else if(xctx->paste_from == 1 && stat(sel_file, &buf) && (xctx->ui_state & STARTMERGE)) { abort_operation(); } /*xschem window *receiving* selected objects diff --git a/src/move.c b/src/move.c index 15274b48..926a6800 100644 --- a/src/move.c +++ b/src/move.c @@ -913,6 +913,7 @@ void move_objects(int what, int merge, double dx, double dy) } if(what & ABORT) /* draw objects while moving */ { + xctx->paste_from = 0; draw_selection(xctx->gctiled,0); if(xctx->kissing) { pop_undo(0, 0); diff --git a/src/paste.c b/src/paste.c index 17712a0c..5a04880e 100644 --- a/src/paste.c +++ b/src/paste.c @@ -309,6 +309,7 @@ void merge_file(int selection_load, const char ext[]) rubber = !(selection_load & 8); selection_load &= 7; + xctx->paste_from = 0; if(selection_load==0) { if(!strcmp(ext,"")) { @@ -317,6 +318,7 @@ void merge_file(int selection_load, const char ext[]) if(!strcmp(tclresult(),"")) return; my_strncpy(filename, (char *)tclresult(), S(filename)); name = filename; + xctx->paste_from = 3; } else { my_strncpy(filename, ext, S(filename)); @@ -327,11 +329,12 @@ void merge_file(int selection_load, const char ext[]) else if(selection_load==1) { name = sel_file; + xctx->paste_from = 1; } else /* selection_load==2, clipboard load */ { name = clip_file; - xctx->paste_from = 1; + xctx->paste_from = 2; } if(is_generator(name)) generator = 1; @@ -431,14 +434,15 @@ void merge_file(int selection_load, const char ext[]) else fclose(fd); xctx->ui_state |= STARTMERGE; - dbg(1, "merge_file(): loaded file:wire=%d inst=%d ui_state=%ld\n", - xctx->wires , xctx->instances, xctx->ui_state); + dbg(1, "End merge_file(): loaded file %s: wire=%d inst=%d ui_state=%ld\n", + name, xctx->wires , xctx->instances, xctx->ui_state); move_objects(START,0,0,0); xctx->mousex_snap = xctx->mx_double_save; xctx->mousey_snap = xctx->my_double_save; if(rubber) move_objects(RUBBER,0,0,0); } else { dbg(0, "merge_file(): can not open %s\n", name); + xctx->paste_from = 0; } set_modify(1); } diff --git a/src/xschem.h b/src/xschem.h index 94440c9a..72e8d494 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -948,7 +948,9 @@ typedef struct { int simdata_ninst; int modified; int semaphore; - int paste_from; /* set to non zero if paste from clipboard is called */ + int paste_from; /* set to 1 if paste from clipboard is called , + * 2 if paste from selection + * 3 if paste from user provided file */ size_t tok_size; char netlist_name[PATH_MAX]; char current_dirname[PATH_MAX];