editprop.c->update_symbol(): recalculate bbox for dynamic symbols (floaters and generators) when attributes are changed. xschem.tcl: cleanly report errors in file mkdir instructions in case of permission issues

This commit is contained in:
stefan schippers 2023-09-18 09:39:52 +02:00
parent 306271e247
commit 690486c848
2 changed files with 44 additions and 11 deletions

View File

@ -1307,7 +1307,7 @@ static int update_symbol(const char *result, int x, int first_sel)
int pushed=0;
int *ii = &xctx->edit_sym_i; /* static var */
int *netl_com = &xctx->netlist_commands; /* static var */
int floaters, modified = 0;
int generator = 0,floaters, modified = 0;
dbg(1, "update_symbol(): entering\n");
*ii=xctx->sel_array[first_sel].n;
@ -1329,13 +1329,14 @@ static int update_symbol(const char *result, int x, int first_sel)
dbg(1, "update_symbol(): new_prop=%s\n", new_prop);
}
my_strncpy(symbol, (char *) tclgetvar("symbol") , S(symbol));
generator = is_generator(symbol);
dbg(1, "update_symbol(): symbol=%s\n", symbol);
no_change_props=atoi(tclgetvar("no_change_attrs") );
only_different=atoi(tclgetvar("preserve_unchanged_attrs") );
copy_cell=atoi(tclgetvar("user_wants_copy_cell") );
/* if there are floaters or generators (dynamic symbols, pCells) do not collect
* list of things to redraw, just redraw all screen */
floaters = there_are_floaters() || is_generator(symbol);
floaters = there_are_floaters() || generator;
if(!floaters) bbox(START,0.0,0.0,0.0,0.0);
/* 20191227 necessary? --> Yes since a symbol copy has already been done
in edit_symbol_property() -> tcl edit_prop, this ensures new symbol is loaded from disk.
@ -1452,6 +1453,9 @@ static int update_symbol(const char *result, int x, int first_sel)
xctx->prep_hash_inst=0;
xctx->prep_net_structs=0;
xctx->prep_hi_structs=0;
if(floaters) { /* we need to recalculate bbox of dynamic symbols (floaters/ generators) after prop changes */
symbol_bbox(*ii, &xctx->inst[*ii].x1, &xctx->inst[*ii].y1, &xctx->inst[*ii].x2, &xctx->inst[*ii].y2);
}
if(!floaters) {
find_inst_to_be_redrawn(1 + 4 + 32); /* 32: call prepare_netlist_structs(0) */
find_inst_to_be_redrawn(16); /* clear data */

View File

@ -2669,13 +2669,19 @@ proc setglob {dir} {
}
proc load_file_dialog_mkdir {dir} {
global myload_dir1
global myload_dir1 has_x
if { $dir ne {} } {
file mkdir "${myload_dir1}/$dir"
if {[catch {file mkdir "${myload_dir1}/$dir"} err]} {
puts $err
if {$has_x} {
tk_messageBox -message "$err" -icon error -parent [xschem get topwindow] -type ok
}
}
setglob ${myload_dir1}
myload_set_colors2
}
}
proc load_file_dialog_up {dir} {
global myload_dir1
bind .load.l.paneright.draw <Expose> {}
@ -3285,10 +3291,15 @@ proc make_symbol_lcc {name} {
# create simulation dir 'simulation/' under current schematic directory
proc simuldir {} {
global netlist_dir local_netlist_dir
global netlist_dir local_netlist_dir has_x
if { $local_netlist_dir == 1 } {
set simdir [xschem get current_dirname]/simulation
file mkdir $simdir
if {[catch {file mkdir "$simdir"} err]} {
puts $err
if {$has_x} {
tk_messageBox -message "$err" -icon error -parent [xschem get topwindow] -type ok
}
}
set netlist_dir $simdir
return $netlist_dir
}
@ -3308,11 +3319,17 @@ proc simuldir {} {
# Return current netlist directory
#
proc set_netlist_dir { force {dir {} }} {
global netlist_dir env OS
global netlist_dir env OS has_x
if { ( $force == 0 ) && ( $netlist_dir ne {} ) } {
if {![file exist $netlist_dir]} {
file mkdir $netlist_dir
if {[catch {file mkdir "$netlist_dir"} err]} {
puts $err
if {$has_x} {
tk_messageBox -message "$err" -icon error -parent [xschem get topwindow] -type ok
}
}
}
regsub {^~/} $netlist_dir ${env(HOME)}/ netlist_dir
return $netlist_dir
@ -3336,7 +3353,13 @@ proc set_netlist_dir { force {dir {} }} {
if {$new_dir ne {} } {
if {![file exist $new_dir]} {
file mkdir $new_dir
if {[catch {file mkdir "$new_dir"} err]} {
puts $err
if {$has_x} {
tk_messageBox -message "$err" -icon error -parent [xschem get topwindow] -type ok
}
}
}
set netlist_dir $new_dir
}
@ -4718,10 +4741,16 @@ proc fix_symbols {n} {
# fetch a remote url into ${XSCHEM_TMP_DIR}/xschem_web
proc download_url {url} {
global XSCHEM_TMP_DIR download_url_helper OS
global XSCHEM_TMP_DIR download_url_helper OS has_x
# puts "download_url: $url"
if {![file exists ${XSCHEM_TMP_DIR}/xschem_web]} {
file mkdir ${XSCHEM_TMP_DIR}/xschem_web
if {[catch {file mkdir "${XSCHEM_TMP_DIR}/xschem_web"} err]} {
puts $err
if {$has_x} {
tk_messageBox -message "$err" -icon error -parent [xschem get topwindow] -type ok
}
}
}
if {$OS eq "Windows"} {
set cmd "cmd /c \"cd ${XSCHEM_TMP_DIR}/xschem_web & $download_url_helper $url\""