catch all calls to .menubar entruconfigure commands to change bg color of buttons to avoid errors if buttons are removed

This commit is contained in:
stefan schippers 2025-08-09 10:57:17 +02:00
parent 24ff9ab8f0
commit 7e20ea0127
6 changed files with 28 additions and 28 deletions

View File

@ -164,26 +164,26 @@ int set_modify(int mod)
/* Do not configure buttons if displaying in preview window */
if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) {
char s[256];
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background $simulate_bg", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Netlist -background $simulate_bg}", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist $simulate_bg", NULL);
my_snprintf(s, S(s), "tctx::%s_simulate_id", xctx->current_win_path);
if(tclgetvar(s)) {
tclvareval(xctx->top_path, ".menubar entryconfigure Simulate -background ", tclresult(), NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Simulate -background}", tclresult(), NULL);
tclvareval("set tctx::", xctx->current_win_path, "_simulate ", tclresult(), NULL);
} else {
tclvareval(xctx->top_path, ".menubar entryconfigure Simulate -background $simulate_bg", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Simulate -background $simulate_bg}", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_simulate $simulate_bg", NULL);
}
}
if(sch_waves_loaded() >= 0) {
if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) {
tclvareval("set tctx::", xctx->current_win_path, "_waves Green", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background Green", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Waves -background Green}", NULL);
}
} else {
if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) {
tclvareval("set tctx::", xctx->current_win_path, "_waves $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background $simulate_bg", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Waves -background $simulate_bg}", NULL);
}
}
}

View File

@ -3163,12 +3163,12 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
}
if(err) {
if(has_x) {
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background red", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Netlist -background red}", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist red", NULL);
}
} else {
if(has_x) {
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background Green", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Netlist -background Green}", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist Green", NULL);
}
}

View File

@ -890,7 +890,7 @@ void free_rawfile(Raw **rawptr, int dr, int no_warning)
if(has_x) {
tclvareval("set tctx::", xctx->current_win_path, "_waves $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background $simulate_bg", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Waves -background $simulate_bg}", NULL);
}
if(dr) draw();
@ -1060,10 +1060,10 @@ int raw_read(const char *f, Raw **rawptr, const char *type, int no_warning, doub
if(has_x) {
if(sch_waves_loaded() >= 0) {
tclvareval("set tctx::", xctx->current_win_path, "_waves Green", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background Green", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Waves -background Green}", NULL);
} else {
tclvareval("set tctx::", xctx->current_win_path, "_waves $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background $simulate_bg", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Waves -background $simulate_bg}", NULL);
}
}
return res;
@ -3453,7 +3453,7 @@ int save_schematic(const char *schname, int fast) /* 20171020 added return value
if(fast) set_modify(2); /* only clear modified flag, no title/tab/sim buttons update */
else set_modify(0);
}
tclvareval(xctx->top_path, ".menubar entryconfigure Simulate -background $simulate_bg", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Simulate -background $simulate_bg}", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_simulate $simulate_bg", NULL);
tclvareval("catch {unset tctx::", xctx->current_win_path, "_simulate_id}", NULL);
/* set local simulation directory if local_netlist_dir is set*/

View File

@ -3506,12 +3506,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
if(err) {
if(has_x) {
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background red", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Netlist -background red}", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist red", NULL);
}
} else {
if(has_x) {
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background Green", NULL);
tclvareval(xctx->top_path, "catch {.menubar entryconfigure Netlist -background Green}", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist Green", NULL);
}
}

View File

@ -1641,7 +1641,7 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch
tclvareval("save_ctx ", xctx->current_win_path, NULL);
(*window_count)++;
if(has_x) {
tclvareval("[xschem get top_path].menubar entryconfigure Simulate -background $simulate_bg", NULL);
tclvareval("catch {[xschem get top_path].menubar entryconfigure Simulate -background $simulate_bg}", NULL);
tcleval(".menubar.view entryconfigure {Tabbed interface} -state disabled");
}
n = -1;
@ -3042,7 +3042,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
/* */
/* SOURCE XSCHEMRC SUPPLIED TCL FILES */
/* */
tcleval("update; source_user_tcl_files");
tcleval("source_user_tcl_files");
if(cli_opt_filename[0]) {
char f[PATH_MAX];
@ -3172,7 +3172,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
/* to be executed on any new window */
/* creation */
/* */
tcleval("eval_user_startup_commands");
tcleval("update; eval_user_startup_commands");
/* source tcl file given on command line with --script */
if(cli_opt_tcl_script[0]) {

View File

@ -980,7 +980,7 @@ proc netlist {source_file show netlist_file} {
set waves_var tctx::${win_path}_waves
if {[info exists has_x] && $waves_var ne $simulate_bg} {
set $waves_var orange
$top_path.menubar entryconfigure Waves -background orange
catch {$top_path.menubar entryconfigure Waves -background orange}
}
set netlist_type [xschem get netlist_type]
@ -2640,7 +2640,7 @@ proc simulate_from_button {{callback {}}} {
# something went wrong. Forget about the process
unset tctx::[xschem get current_win_path]_simulate_id
set tctx::[xschem get current_win_path]_simulate $simulate_bg
[xschem get top_path].menubar entryconfigure Simulate -background $simulate_bg
catch {[xschem get top_path].menubar entryconfigure Simulate -background $simulate_bg}
}
}
}
@ -2711,7 +2711,7 @@ proc simulate {{callback {}}} {
if {[info exists has_x] && $id >= 0 } {
set tctx::[xschem get current_win_path]_simulate_id $id
set button_path [xschem get top_path].menubar
$button_path entryconfigure Simulate -background orange
catch {$button_path entryconfigure Simulate -background orange}
set tctx::[xschem get current_win_path]_simulate orange
}
@ -8493,17 +8493,17 @@ proc set_simulate_button {top_path win_path} {
if {![info exists execute(exitcode,last)]} {
if { $current_win eq $win_path} {
$sim_button entryconfigure Simulate -background $simulate_bg
catch {$sim_button entryconfigure Simulate -background $simulate_bg}
}
set $simvar $simulate_bg
} elseif { $execute(exitcode,last) == 0} {
if { $current_win eq $win_path} {
$sim_button entryconfigure Simulate -background Green
catch {$sim_button entryconfigure Simulate -background Green}
}
set $simvar Green
} else {
if { $current_win eq $win_path} {
$sim_button entryconfigure Simulate -background red
catch {$sim_button entryconfigure Simulate -background red}
}
set $simvar red
}
@ -8522,21 +8522,21 @@ proc set_sim_netlist_waves_buttons {} {
set sim_var tctx::${win_path}_simulate
set waves_var tctx::${win_path}_waves
if {![info exists $netlist_var] || [set $netlist_var] eq $simulate_bg} {
$top_path.menubar entryconfigure Netlist -background $simulate_bg
catch {$top_path.menubar entryconfigure Netlist -background $simulate_bg}
} else {
$top_path.menubar entryconfigure Netlist -background [set $netlist_var]
catch {$top_path.menubar entryconfigure Netlist -background [set $netlist_var]}
}
if {![info exists $sim_var] || [set $sim_var] eq $simulate_bg} {
$top_path.menubar entryconfigure Simulate -background $simulate_bg
catch {$top_path.menubar entryconfigure Simulate -background $simulate_bg}
} else {
$top_path.menubar entryconfigure Simulate -background [set $sim_var]
catch {$top_path.menubar entryconfigure Simulate -background [set $sim_var]}
}
if {![info exists $waves_var] || [set $waves_var] eq $simulate_bg} {
$top_path.menubar entryconfigure Waves -background $simulate_bg
catch {$top_path.menubar entryconfigure Waves -background $simulate_bg}
} else {
$top_path.menubar entryconfigure Waves -background [set $waves_var]
catch {$top_path.menubar entryconfigure Waves -background [set $waves_var]}
}
}