fix a regression in merge_file(0,...) from user provided file being aborted

This commit is contained in:
stefan schippers 2024-03-07 18:32:42 +01:00
parent 71b1b52384
commit 132d335757
4 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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];