do not show "already open" warning if re-opening same schematic in same window/tab; new_file_browser: "Save current window" button will ask where to save, to avoid dangerous overwrites

This commit is contained in:
stefan schippers 2025-11-02 10:23:58 +01:00
parent aa240c4244
commit a41d142562
6 changed files with 20 additions and 12 deletions

View File

@ -624,7 +624,8 @@ void ask_new_file(int in_new_window, char *filename)
int skip = 0;
dbg(1, "ask_new_file(): load: f=%s\n", f);
if(check_loaded(f, win_path) && !filename) {
if(check_loaded(f, win_path) && !filename &&
xctx->current_win_path && strcmp(win_path, xctx->current_win_path)) {
char msg[PATH_MAX + 100];
my_snprintf(msg, S(msg),
"tk_messageBox -type okcancel -icon warning -parent [xschem get topwindow] "

View File

@ -3089,7 +3089,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int skip = 0;
dbg(1, "scheduler(): load: filename=%s\n", f);
my_strncpy(f, abs_sym_path(f, ""), S(f));
if(!force && f[0] && check_loaded(f, win_path) ) {
if(!force && f[0] && check_loaded(f, win_path) &&
xctx->current_win_path && strcmp(win_path, xctx->current_win_path)) {
char msg[PATH_MAX + 100];
my_snprintf(msg, S(msg),
"tk_messageBox -type okcancel -icon warning -parent [xschem get topwindow] "
@ -3173,7 +3174,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(f[0]) {
char win_path[WINDOW_PATH_SIZE];
dbg(1, "f=%s\n", f);
if(check_loaded(f, win_path)) {
if(check_loaded(f, win_path) && xctx->current_win_path && strcmp(win_path, xctx->current_win_path)) {
char msg[PATH_MAX + 100];
my_snprintf(msg, S(msg),
"tk_messageBox -type okcancel -icon warning -parent [xschem get topwindow] "

View File

@ -5397,14 +5397,14 @@ proc file_chooser_saveas {} {
if {[file isdirectory $f]} {return}
if {[xschem get modified]} { ;# modified
if {[xschem get schname] eq $f} { ;# file name not changed
xschem saveas $f
xschem saveas
.ins.top2.save configure -bg [option get . background {}]
file_chooser_filelist
} else { ;# file name changed
set answer [tk_messageBox -message "Warning: file $f already exists. Overwrite?" \
-icon warning -parent .ins -type okcancel]
if {$answer ne {ok}} { return }
xschem saveas $f
xschem saveas
.ins.top2.save configure -bg [option get . background {}]
file_chooser_filelist
}
@ -5415,7 +5415,7 @@ proc file_chooser_saveas {} {
set answer [tk_messageBox -message "Warning: file $f already exists. Overwrite?" \
-icon warning -parent .ins -type okcancel]
if {$answer ne {ok}} { return }
xschem saveas $f
xschem saveas
.ins.top2.save configure -bg [option get . background {}]
file_chooser_filelist
}
@ -5522,6 +5522,8 @@ proc file_chooser {} {
-readonlybackground [option get . background {}] -takefocus 0
button .ins.top2.save -takefocus 0 -text {Save current window} -command {
set file_chooser(regex) {}
file_chooser_select [xschem get schname]
file_chooser_saveas
}
button .ins.top2.delete -takefocus 0 -text {Delete} -command {

View File

@ -1,4 +1,4 @@
v {xschem version=3.4.5 file_version=1.2
v {xschem version=3.4.8RC file_version=1.3
*
* This file is part of XSCHEM,
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
@ -23,6 +23,7 @@ G {}
K {}
V {}
S {}
F {}
E {}
B 2 1240 -590 2040 -80 {flags=graph
y1=0
@ -149,7 +150,8 @@ schematic=comp3_pex2
spice_sym_def="tcleval(.include [abs_sym_path comp3_pex2.cir])"
verilog_sym_def="verilog stuff"
vhdl_sym_def="vhdl stuff"}
vhdl_sym_def="vhdl stuff"
tclcommand="textwindow [abs_sym_path comp3_pex2.cir]"}
C {comp3.sym} 480 -580 0 0 {name=x5
schematic=comp3_empty.sch}
C {comp3.sym} 480 -290 0 0 {name=x6

View File

@ -94,11 +94,12 @@ T {This symbol is described by a diff_amp.va Verilog-A file} 100 -920 0 0 0.4 0.
N 180 -450 320 -450 {lab=B}
N 80 -530 320 -530 {lab=A}
N 520 -490 640 -490 {lab=Z}
N 60 -290 180 -290 {lab=0}
N 80 -290 180 -290 {lab=0}
N 180 -330 180 -290 {lab=0}
N 80 -330 80 -290 {lab=0}
N 80 -530 80 -390 {lab=A}
N 180 -450 180 -390 {lab=B}
N 60 -290 80 -290 {lab=0}
C {lab_pin.sym} 640 -490 0 1 {name=p1 sig_type=std_logic lab=Z}
C {lab_pin.sym} 80 -530 0 0 {name=p2 sig_type=std_logic lab=A}
C {lab_pin.sym} 180 -450 0 0 {name=p3 sig_type=std_logic lab=B}

View File

@ -8,8 +8,8 @@ E {}
B 2 600 -930 1340 -590 {flags=graph
y1=0
y2=2
ypos1=0.12703394
ypos2=1.7910429
ypos1=-0.021063888
ypos2=2.0015494
divy=5
subdivy=1
unity=1
@ -61,7 +61,7 @@ Analog nodes can be plotted and saved
in raw file.} 880 -400 0 0 0.3 0.3 {layer=7}
N 70 -230 70 -210 {lab=CLK}
N 410 -430 460 -430 {lab=CLK}
N 600 -430 860 -430 {bus=1 lab=count_out[3..0]}
N 820 -430 860 -430 {bus=1 lab=count_out[3..0]}
N 820 -430 820 -390 {lab=count_out[3..0]}
N 1210 -150 1210 -130 {lab=SUM}
N 790 -150 1210 -150 {lab=SUM}
@ -69,6 +69,7 @@ N 790 -240 790 -210 {lab=count_out3}
N 910 -240 910 -210 {lab=count_out2}
N 1030 -240 1030 -210 {lab=count_out1}
N 1150 -240 1150 -210 {lab=count_out0}
N 600 -430 820 -430 {bus=1 lab=count_out[3..0]}
C {vsource.sym} 70 -180 0 0 {name=VCLOCK value="pulse 0 'VDD' 49995p 10p 10p 49990p 100n"}
C {lab_pin.sym} 70 -150 0 0 {name=p6 lab=0}
C {lab_pin.sym} 70 -230 0 0 {name=p13 lab=CLK}