From 8f3fedab1fa8e4447b3620a9440cb9d94f94d522 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 22 Oct 2023 02:53:03 +0200 Subject: [PATCH] fix a bug when closing with ctrl-q (ie from callback(), calling proc quit_xschem) and there are multiple windows, some with changed data (switch_tab() was skipped due to xctx->semaphore). Process status dialog window will not be updated if vertical slider is not positioned to bottom --- src/callback.c | 5 +++- src/xinit.c | 1 + src/xschem.tcl | 25 +++++++++-------- xschem_library/examples/poweramp.sch | 42 ++++++++++++++++++++++++++-- xschem_library/rom8k/rom8k.sch | 4 +-- 5 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/callback.c b/src/callback.c index a7a001eb..2aaf1dfe 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1922,6 +1922,9 @@ int rstate; /* (reduced state, without ShiftMask) */ if(key=='q' && rstate==ControlMask) /* quit xschem */ { if(xctx->semaphore >= 2) break; + /* must be set to zero, otherwise switch_tab/switch_win does not proceed + * and these are necessary when closing tabs/windows */ + xctx->semaphore = 0; tcleval("quit_xschem"); break; } @@ -3007,7 +3010,7 @@ int rstate; /* (reduced state, without ShiftMask) */ break; } /* switch(event) */ - xctx->semaphore--; + if(xctx->semaphore > 0) xctx->semaphore--; if(redraw_only) { xctx->semaphore--; /* decrement articially incremented semaphore (see above) */ dbg(1, "callback(): semaphore >=2 restoring window context: %s <-- %s\n", old_winpath, winpath); diff --git a/src/xinit.c b/src/xinit.c index c2b3a7b8..3e816bf8 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1399,6 +1399,7 @@ static int switch_window(int *window_count, const char *win_path, int tcl_ctx) int n; char my_win_path[80]; Tk_Window tkwin=NULL; + if(xctx->semaphore) return 1; /* some editing operation ongoing. do nothing */ if(!win_path) { dbg(0, "switch_window(): no filename or window path given\n"); return 1; diff --git a/src/xschem.tcl b/src/xschem.tcl index d50803d2..6b65d671 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -383,18 +383,21 @@ proc update_process_status {lb} { set exists 0 set selected [$lb curselection] if { [winfo exists .pstat] } { - if { $selected ne {} && [llength $selected] == 1} { - .pstat.text delete 1.0 end - set idx $selected - set cmd1 [$lb get $idx] - foreach {id pid cmd2} [get_running_cmds] { - if { $cmd1 eq $cmd2 } { - if {[catch { set t $execute(data,$id) } err]} { - set t $err + set pos [lindex [.pstat.text yview] 1] + if {$pos == 1} { + if { $selected ne {} && [llength $selected] == 1} { + .pstat.text delete 1.0 end + set idx $selected + set cmd1 [$lb get $idx] + foreach {id pid cmd2} [get_running_cmds] { + if { $cmd1 eq $cmd2 } { + if {[catch { set t $execute(data,$id) } err]} { + set t $err + } + .pstat.text insert 1.0 $t + .pstat.text yview moveto 1 + break } - .pstat.text insert 1.0 $t - .pstat.text yview moveto 1 - break } } } diff --git a/xschem_library/examples/poweramp.sch b/xschem_library/examples/poweramp.sch index cc81ebd6..466986a2 100644 --- a/xschem_library/examples/poweramp.sch +++ b/xschem_library/examples/poweramp.sch @@ -1,4 +1,4 @@ -v {xschem version=3.4.4 file_version=1.2 +v {xschem version=3.4.5 file_version=1.2 * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit @@ -331,9 +331,10 @@ xschem raw_read $netlist_dir/poweramp.raw tran C {launcher.sym} 1450 -30 0 0 {name=h6 descr="Graph Manual page" url="https://xschem.sourceforge.io/stefan/xschem_man/graphs.html"} -C {simulator_commands.sym} 1020 -450 0 0 {name=COMMANDS +C {simulator_commands.sym} 1020 -670 0 0 {name=NGSPICE simulator=ngspice only_toplevel=false +spice_ignore=0 value=" .option ITL4=20000 ITL5=0 vvss vss 0 dc 0 @@ -359,7 +360,7 @@ save p(r*) p(v*) write poweramp.raw .endc "} -C {simulator_commands.sym} 1020 -650 0 0 {name=COMMANDS1 +C {simulator_commands.sym} 1020 -870 0 0 {name=COMMANDS1 simulator=xyce only_toplevel=false value=" @@ -387,3 +388,38 @@ tclcommand=" xschem raw_read $netlist_dir/poweramp_xyce.raw tran " } +C {simulator_commands.sym} 1020 -480 0 0 {name=NGSPICE_BATCH +simulator=ngspice +spice_ignore=1 +only_toplevel=false +value=" +.option ITL4=20000 ITL5=0 +vvss vss 0 dc 0 +.temp 30 + +.param frequ=5k +.param gain=45 +.option savecurrents + +** models are generally not free: you must download +** SPICE models for active devices and put them into the below +** referenced file in simulation directory. +.include \\"models_poweramp.txt\\" +.save all +.op +.tran 8e-7 0.07 uic +"} +C {launcher.sym} 960 -330 0 0 {name=h4 +descr="Swap interactive +/batch mode" +tclcommand="proc simswap \{\} \{ + set x [xschem getprop instance NGSPICE spice_ignore] + xschem setprop instance NGSPICE_BATCH spice_ignore $x + set x [expr \{ !$x\}] + xschem setprop instance NGSPICE spice_ignore $x +\} + +simswap + +" +} diff --git a/xschem_library/rom8k/rom8k.sch b/xschem_library/rom8k/rom8k.sch index fddb5c39..c5ab19ab 100644 --- a/xschem_library/rom8k/rom8k.sch +++ b/xschem_library/rom8k/rom8k.sch @@ -366,7 +366,7 @@ descr="Graph Manual page" url="https://xschem.sourceforge.io/stefan/xschem_man/graphs.html"} C {simulator_commands.sym} 470 -150 0 0 {name=INTERACTIVE simulator=ngspice -spice_ignore=1 +spice_ignore=0 only_toplevel=false value=" .options SCALE=0.10 @@ -484,7 +484,7 @@ tclcommand=" } C {simulator_commands.sym} 340 -150 0 0 {name=BATCH_MODE simulator=ngspice -spice_ignore=0 +spice_ignore=1 only_toplevel=false value=" .options SCALE=0.10