diff --git a/src/xinit.c b/src/xinit.c index 972c901d..f221f290 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1452,7 +1452,6 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch save_xctx[i] = NULL; my_strncpy(window_path[i], "", S(window_path[i])); } - tclvareval("save_ctx ", xctx->current_win_path, NULL); save_xctx[0] = xctx; /* save current schematic */ /* window_path[0] = Tk_NameToWindow(interp, ".drw", mainwindow); */ my_strncpy(window_path[0], xctx->current_win_path, S(window_path[0])); @@ -1461,6 +1460,7 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch dbg(0, "new_schematic(\"create\"...): no more free slots\n"); return; /* no more free slots */ } + tclvareval("save_ctx ", xctx->current_win_path, NULL); (*window_count)++; tclvareval("[xschem get top_path].menubar.simulate configure -bg $simulate_bg", NULL); tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state disabled"); @@ -1545,7 +1545,6 @@ static void create_new_tab(int *window_count, const char *noconfirm, const char save_xctx[i] = NULL; my_strncpy(window_path[i], "", S(window_path[i])); } - tclvareval("save_ctx ", xctx->current_win_path, NULL); save_xctx[0] = xctx; /* save current schematic */ my_strncpy(window_path[0], xctx->current_win_path, S(window_path[0])); } @@ -1553,6 +1552,7 @@ static void create_new_tab(int *window_count, const char *noconfirm, const char dbg(0, "new_schematic(\"new_tab\"...): no more free slots\n"); return; /* no more free slots */ } + tclvareval("save_ctx ", xctx->current_win_path, NULL); (*window_count)++; tclvareval("[xschem get top_path].menubar.simulate configure -bg $simulate_bg", NULL); tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state disabled"); diff --git a/src/xschem.tcl b/src/xschem.tcl index 6b41fda3..b8daaf39 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -5511,6 +5511,12 @@ proc restore_ctx {context} { } } + +# context is saved in array variable in tctx:: namespace. +# to get list of array names: +# array names tctx::.drw +# array names tctx::.x1.drw +# ..... proc save_ctx {context} { global has_x if {![info exists has_x]} {return} @@ -6275,11 +6281,20 @@ proc set_initial_dirs {} { } } +# called whenever XSCHEM_LUBRARY_PATH changes (see trace command at end) +proc trace_set_paths {varname idxname op} { + if {$varname eq {XSCHEM_LIBRARY_PATH} } { + # puts stderr "executing set_paths after XSCHEM_LIBRARY_PATH change" + uplevel #0 set_paths + } +} + # when XSCHEM_LIBRARY_PATH is changed call this function to refresh and cache # new library search path. proc set_paths {} { global XSCHEM_LIBRARY_PATH env pathlist OS add_all_windows_drives set pathlist {} + # puts stderr "caching search paths" if { [info exists XSCHEM_LIBRARY_PATH] } { if {$OS == "Windows"} { set pathlist_orig [split $XSCHEM_LIBRARY_PATH \;] @@ -6733,3 +6748,6 @@ if { $show_infowindow } { wm deiconify .infotext } setup_tcp_xschem setup_tcp_bespice +# automatically build pathlist whenever XSCHEM_LIBRARY_PATH changes +trace add variable XSCHEM_LIBRARY_PATH write trace_set_paths +