fix compare schematics if no file for schematic to compare with is given. In this case compare current schematic with saved version. Also issue a warning if swapping compare schematics if comparing schematic with disk version of itself.

This commit is contained in:
stefan schippers 2023-06-06 19:39:40 +02:00
parent b23d7518bb
commit b6e9ab33cc
4 changed files with 9 additions and 2 deletions

View File

@ -1108,7 +1108,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
/* redraw selection on expose, needed if no backing store available on the server 20171112 */
XSetClipRectangles(display, xctx->gc[SELLAYER], 0,0, xr, 1, Unsorted);
rebuild_selected_array();
if(tclgetboolvar("compare_sch") && xctx->sch_to_compare[0]){
if(tclgetboolvar("compare_sch") /* && xctx->sch_to_compare[0] */){
compare_schematics("");
} else {
draw_selection(xctx->gc[SELLAYER],0);

View File

@ -3825,7 +3825,7 @@ void draw(void)
xctx->xrect[0].width, xctx->xrect[0].height);
#endif
}
if(tclgetboolvar("compare_sch") && xctx->sch_to_compare[0]){
if(tclgetboolvar("compare_sch") /* && xctx->sch_to_compare[0]*/ ){
compare_schematics("");
} else {
draw_selection(xctx->gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */

View File

@ -685,6 +685,7 @@ int compare_schematics(const char *f)
int_hash_init(&table1, HASHSIZE);
int_hash_init(&table2, HASHSIZE);
dbg(1, "compare_schematics(): xctx->sch_to_compare=%s\n", xctx->sch_to_compare);
/* set filename of schematic to compare */
if(f == NULL) {
tcleval("load_file_dialog {Schematic to compare with} *.\\{sch,sym\\} INITIALLOADDIR");

View File

@ -4773,6 +4773,12 @@ proc swap_compare_schematics {} {
global compare_sch XSCHEM_TMP_DIR
set sch1 [xschem get schname]
set sch2 [xschem get sch_to_compare]
if { $sch1 eq $sch2} {
set msg "Swapping with same schematic name on disk. Suggest to cancel to avoid losing/overwriting data"
set answer [tk_messageBox -message $msg \
-icon warning -parent [xschem get topwindow] -type okcancel]
if { $answer ne {ok} } {return}
}
puts "swap_compare_schematics:\n sch1=$sch1\n sch2=$sch2"
if {$sch2 ne {}} {
xschem load $sch2 nofullzoom gui