From b072701cbdf316892cba4c9edff446fca8b7e4ee Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 14 Oct 2025 00:31:47 +0200 Subject: [PATCH] fix regresions in get_sym_name() and get_sch_from_sym(), use catch {...} in proc edit_prop for xschem getprop symbol ... command if symbol not found --- src/actions.c | 16 ++++++++-------- src/xschem.tcl | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/actions.c b/src/actions.c index 93833fa5..fc007f7c 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1898,9 +1898,11 @@ const char *get_sym_name(int inst, int ndir, int ext, int abs_path) /* resolve schematic=generator.tcl( @n ) where n=11 is defined in instance attrs */ my_strdup2(_ALLOC_ID_, &sch, get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6)); schematic_token_found = xctx->tok_size; - my_strdup2(_ALLOC_ID_, &sch, translate3(sch, 1, xctx->inst[inst].prop_ptr, NULL, NULL, NULL)); - my_strdup2(_ALLOC_ID_, &sch, tcl_hook2( - str_replace(sch, "@symname", get_cell(xctx->inst[inst].name, 0), '\\', -1))); + if(sch[0]) + my_strdup2(_ALLOC_ID_, &sch, translate3(sch, 1, xctx->inst[inst].prop_ptr, NULL, NULL, NULL)); + if(sch[0]) + my_strdup2(_ALLOC_ID_, &sch, tcl_hook2( + str_replace(sch, "@symname", get_cell(xctx->inst[inst].name, 0), '\\', -1))); /* * sch = tcl_hook2(str_replace(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6), "@symname", @@ -2255,16 +2257,14 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback) /* instance based symbol selection */ /* resolve schematic=generator.tcl( @n ) where n=11 is defined in instance attrs */ my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6)); - my_strdup2(_ALLOC_ID_, &str_tmp, translate3(str_tmp, 1, xctx->inst[inst].prop_ptr, NULL, NULL, NULL)); - my_strdup2(_ALLOC_ID_, &str_tmp, tcl_hook2( - str_replace(str_tmp, "@symname", get_cell(xctx->inst[inst].name, 0), '\\', -1))); - + if(str_tmp[0]) + my_strdup2(_ALLOC_ID_, &str_tmp, translate3(str_tmp, 1, xctx->inst[inst].prop_ptr, NULL, NULL, NULL)); /* * my_strdup(_ALLOC_ID_, &str_tmp, translate3(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6), * 1, xctx->inst[inst].prop_ptr, NULL, NULL, NULL)); */ } - if(!str_tmp) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 6)); + if(!str_tmp[0]) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 6)); if(str_tmp[0]) { /* schematic attribute in symbol or instance was given */ /* @symname in schematic attribute will be replaced with symbol name */ my_strdup2(_ALLOC_ID_, &sch, tcl_hook2(str_replace(str_tmp, "@symname", diff --git a/src/xschem.tcl b/src/xschem.tcl index a27a89a6..87bb8c54 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -7084,7 +7084,9 @@ proc edit_prop {txtlabel} { set sym_sel_attr [xschem get_tok $tctx::retval select] ;# get from instance if {$sym_sel_attr eq {}} { - set sym_sel_attr [xschem getprop symbol $symbol select] ;# not found in instance, get from symbol + if {[catch {xschem getprop symbol $symbol select} sym_sel_attr]} { + set sym_sel_attr {} + } } if {$sym_sel_attr eq {*}} { .dialog.symprop tag add sel 1.0 {end - 1 chars}