when descending from a modified schematic with highlight nets and not saving schematic before descending, clear highlights to avoid inconsistent state when returning back. save() and save_schematic() have more decent return values
This commit is contained in:
parent
fddd3f84fb
commit
1c37e7eeee
|
|
@ -352,25 +352,26 @@ int samefile(const char *fa, const char *fb)
|
|||
return 0; /* not same of one of the two not existing */
|
||||
}
|
||||
|
||||
int save(int confirm) /* 20171006 add confirm */
|
||||
{
|
||||
int cancel;
|
||||
int save_ok;
|
||||
|
||||
save_ok=0;
|
||||
cancel=0;
|
||||
/* return value:
|
||||
* 1 : file saved or not needed to save since no change
|
||||
* -1 : user cancel
|
||||
* 0 : file not saved due to errors or per user request
|
||||
*/
|
||||
int save(int confirm)
|
||||
{
|
||||
if(xctx->modified)
|
||||
{
|
||||
if(confirm) {
|
||||
tcleval("ask_save");
|
||||
if(!strcmp(tclresult(), "") ) cancel=1;
|
||||
if(!strcmp(tclresult(), "yes") ) save_ok = save_schematic(xctx->sch[xctx->currsch]);
|
||||
if(!strcmp(tclresult(), "") ) return -1; /* user clicks "Cancel" */
|
||||
else if(!strcmp(tclresult(), "yes") ) return save_schematic(xctx->sch[xctx->currsch]);
|
||||
else return 0; /* user clicks "no" */
|
||||
} else {
|
||||
save_ok = save_schematic(xctx->sch[xctx->currsch]);
|
||||
return save_schematic(xctx->sch[xctx->currsch]);
|
||||
}
|
||||
}
|
||||
if(save_ok==-1) return 1;
|
||||
return cancel;
|
||||
return 1; /* circuit not changed: always succeeed */
|
||||
}
|
||||
|
||||
void saveas(const char *f, int type) /* changed name from ask_save_file to saveas 20121201 */
|
||||
|
|
@ -1038,7 +1039,7 @@ void descend_schematic(int instnumber)
|
|||
if(!res[0]) return;
|
||||
dbg(1, "descend_schematic(): saving: %s\n",res);
|
||||
save_ok = save_schematic(res);
|
||||
if(save_ok==-1) return;
|
||||
if(save_ok==0) return;
|
||||
}
|
||||
|
||||
dbg(1, "descend_schematic(): inst type: %s\n", (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type);
|
||||
|
|
@ -1051,7 +1052,18 @@ void descend_schematic(int instnumber)
|
|||
|
||||
if(xctx->modified)
|
||||
{
|
||||
if(save(1)) return;
|
||||
int ret;
|
||||
|
||||
ret = save(1);
|
||||
/* if circuit is changed but not saved before descending
|
||||
* state will be inconsistent when returning, can not propagare hilights
|
||||
* save() return value:
|
||||
* 1 : file saved
|
||||
* -1 : user cancel
|
||||
* 0 : file not saved due to errors or per user request
|
||||
*/
|
||||
if(ret == 0) clear_all_hilights();
|
||||
if(ret == -1) return; /* user cancel */
|
||||
}
|
||||
|
||||
/* build up current hierarchy path */
|
||||
|
|
@ -1136,7 +1148,7 @@ void go_back(int confirm) /* 20171006 add confirm */
|
|||
char filename[PATH_MAX];
|
||||
int prev_sch_type;
|
||||
|
||||
save_ok=0;
|
||||
save_ok=1;
|
||||
prev_sch_type = xctx->netlist_type; /* if CAD_SYMBOL_ATTRS do not hilight_parent_pins */
|
||||
if(xctx->currsch>0)
|
||||
{
|
||||
|
|
@ -1151,7 +1163,7 @@ void go_back(int confirm) /* 20171006 add confirm */
|
|||
save_ok = save_schematic(xctx->sch[xctx->currsch]);
|
||||
}
|
||||
}
|
||||
if(save_ok==-1) return;
|
||||
if(save_ok==0) return;
|
||||
unselect_all();
|
||||
remove_symbols();
|
||||
from_embedded_sym=0;
|
||||
|
|
|
|||
14
src/save.c
14
src/save.c
|
|
@ -961,6 +961,10 @@ void make_schematic(const char *schname)
|
|||
}
|
||||
|
||||
/* ALWAYS call with absolute path in schname!!! */
|
||||
/* return value:
|
||||
* 0 : did not save
|
||||
* 1 : schematic saved
|
||||
*/
|
||||
int save_schematic(const char *schname) /* 20171020 added return value */
|
||||
{
|
||||
FILE *fd;
|
||||
|
|
@ -971,7 +975,7 @@ int save_schematic(const char *schname) /* 20171020 added return value */
|
|||
top_path = xctx->top_path[0] ? xctx->top_path : ".";
|
||||
|
||||
if( strcmp(schname,"") ) my_strncpy(xctx->sch[xctx->currsch], schname, S(xctx->sch[xctx->currsch]));
|
||||
else return -1;
|
||||
else return 0;
|
||||
dbg(1, "save_schematic(): currsch=%d name=%s\n",xctx->currsch, schname);
|
||||
dbg(1, "save_schematic(): sch[currsch]=%s\n", xctx->sch[xctx->currsch]);
|
||||
dbg(1, "save_schematic(): abs_sym_path=%s\n", abs_sym_path(xctx->sch[xctx->currsch], ""));
|
||||
|
|
@ -985,9 +989,7 @@ int save_schematic(const char *schname) /* 20171020 added return value */
|
|||
if(xctx->time_last_modify && xctx->time_last_modify != buf.st_mtime) {
|
||||
Tcl_VarEval(interp, "ask_save \"Schematic file: ", name,
|
||||
"\nHas been changed since opening.\nSave anyway?\" 0", NULL);
|
||||
if(strcmp(tclresult(), "yes") ) {
|
||||
return -1;
|
||||
}
|
||||
if(strcmp(tclresult(), "yes") ) return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -995,7 +997,7 @@ int save_schematic(const char *schname) /* 20171020 added return value */
|
|||
{
|
||||
fprintf(errfp, "save_schematic(): problems opening file %s \n",name);
|
||||
tcleval("alert_ {file opening for write failed!} {}");
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
unselect_all();
|
||||
write_xschem_file(fd);
|
||||
|
|
@ -1013,7 +1015,7 @@ int save_schematic(const char *schname) /* 20171020 added return value */
|
|||
if(!strstr(xctx->sch[xctx->currsch], ".xschem_embedded_")) {
|
||||
set_modify(0);
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* from == -1 --> link symbols to all instances, from 0 to instances-1 */
|
||||
|
|
|
|||
|
|
@ -4142,7 +4142,7 @@ proc build_widgets { {topwin {} } } {
|
|||
$topwin.menubar.tools.menu add command -label "Select conn. wires, stop at junctions" -accelerator {Ctrl-Righ Butt.} \
|
||||
-command { xschem connected_nets 1 }
|
||||
|
||||
$topwin.menubar.hilight.menu add command -label {Highlight net-pin name mismatches on selected instancs} \
|
||||
$topwin.menubar.hilight.menu add command -label {Highlight net-pin name mismatches on selected instances} \
|
||||
-command "xschem net_pin_mismatch" \
|
||||
-accelerator {Shift-X}
|
||||
$topwin.menubar.hilight.menu add command -label {Highlight duplicate instance names} \
|
||||
|
|
|
|||
Loading…
Reference in New Issue