do not ask to save parent schematic containing generator-created symbols even if user tries to modify them, is_xschem_file() now returns SYMBOL|SCHEMATIC|GENERATOR|0

This commit is contained in:
stefan schippers 2023-04-24 09:24:17 +02:00
parent ac95e1e825
commit 7c04b009ec
4 changed files with 43 additions and 11 deletions

View File

@ -1599,7 +1599,11 @@ void go_back(int confirm) /* 20171006 add confirm */
my_strncpy(filename, xctx->sch[xctx->currsch], S(filename));
load_schematic(1, filename, 1, 1);
if(from_embedded_sym) xctx->modified=save_modified; /* to force ask save embedded sym in parent schematic */
/* if we are returning from a symbol created from a generator don't set modified flag on parent
* as these symbols can not be edited / saved as embedded
* xctx->sch_inst_number[xctx->currsch + 1] == -1 --> we came from an inst with no embed flag set */
if(from_embedded_sym && xctx->sch_inst_number[xctx->currsch + 1] != -1)
xctx->modified=save_modified; /* to force ask save embedded sym in parent schematic */
if(xctx->hilight_nets) {
if(prev_sch_type != CAD_SYMBOL_ATTRS) hilight_parent_pins();

View File

@ -473,6 +473,12 @@ void hilight_parent_pins(void)
prepare_netlist_structs(0);
i=xctx->previous_instance[xctx->currsch];
inst_number = xctx->sch_inst_number[xctx->currsch+1];
/* may be set to -1 by descend_symbol to notify we are
* descending into a smbol from an instance with no embed flag set
* this is used when descending into symbols created from generators */
if(inst_number == -1) inst_number = 1;
dbg(1, "hilight_parent_pins(): previous_instance=%d\n", xctx->previous_instance[xctx->currsch]);
dbg(1, "hilight_parent_pins(): inst_number=%d\n", inst_number);
@ -522,6 +528,12 @@ void hilight_child_pins(void)
prepare_netlist_structs(0);
rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER];
inst_number = xctx->sch_inst_number[xctx->currsch];
/* may be set to -1 by descend_symbol to notify we are
* descending into a smbol from an instance with no embed flag set
* this is used when descending into symbols created from generators */
if(inst_number == -1) inst_number = 1;
for(j=0;j<rects; ++j)
{
dbg(1, "hilight_child_pins(): inst_number=%d\n", inst_number);

View File

@ -3935,24 +3935,37 @@ void descend_symbol(void)
!strcmp( (xctx->inst[n].ptr+ xctx->sym)->type,"missing")) return;
}
else return;
/* build up current hierarchy path */
my_strdup(_ALLOC_ID_, &str, xctx->inst[n].instname);
my_strdup(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], xctx->sch_path[xctx->currsch]);
my_strcat(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], str);
my_strcat(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], ".");
xctx->sch_path_hash[xctx->currsch+1] = 0;
my_free(_ALLOC_ID_, &str);
/* store hierarchy of inst attributes and sym templates for hierarchic parameter substitution */
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr,
xctx->inst[n].prop_ptr);
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ,
get_tok_value((xctx->inst[n].ptr+ xctx->sym)->prop_ptr, "template", 0));
xctx->sch_inst_number[xctx->currsch+1] = 1;
my_free(_ALLOC_ID_, &str);
xctx->previous_instance[xctx->currsch]=n;
if(!xctx->inst[n].embed)
/* use -1 to keep track we are descending into symbol from instance with no embed attr
* we use this info to avoid asking to save parent schematic when returning from a symbol
* created from a generator */
xctx->sch_inst_number[xctx->currsch+1] = -1;
else
xctx->sch_inst_number[xctx->currsch+1] = 1; /* inst number we descend into. For symbol always 1 */
xctx->previous_instance[xctx->currsch]=n; /* instance we are descending from */
/* store previous zoom area */
xctx->zoom_array[xctx->currsch].x=xctx->xorigin;
xctx->zoom_array[xctx->currsch].y=xctx->yorigin;
xctx->zoom_array[xctx->currsch].zoom=xctx->zoom;
++xctx->currsch;
++xctx->currsch; /* increment level counter */
if((xctx->inst[n].ptr+ xctx->sym)->flags & EMBEDDED || xctx->inst[n].embed) {
/* save embedded symbol into a temporary file */
my_snprintf(name_embedded, S(name_embedded),

View File

@ -2361,7 +2361,10 @@ proc is_xschem_file {f} {
} else {
fconfigure $fd -translation binary
while { [gets $fd line] >=0 } {
if { $nline == 0 && [regexp {^#!} $line] } { break } ;# this is a script. not an xschem file
if { $nline == 0 && [regexp {^#!} $line] } {
set ret GENERATOR
break
} ;# this is a script. not an xschem file
if { [regexp {^[TKGVSE] \{} $line] } { incr score }
if { [regexp {^[BL] +[0-9]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } {incr score}
if { [regexp {^N +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } {incr score}
@ -2372,7 +2375,7 @@ proc is_xschem_file {f} {
incr nline
}
if { $score > 4 } { set ret 1} ;# Heuristic decision :-)
if { $ret } {
if { $ret ne {0} && $ret ne {GENERATOR}} {
if { $instances} {
set ret SCHEMATIC
} else {
@ -2618,7 +2621,7 @@ proc myload_getresult {loadfile confirm_overwrt} {
}
}
set type [is_xschem_file "$fname"]
if { $type eq {0} } {
if { $type eq {0} || $type eq {GENERATOR} } {
set answer [
alert_ "$fname does not seem to be an xschem file...\nContinue?" {} 0 1]
if { $answer eq {0}} {
@ -2627,7 +2630,7 @@ proc myload_getresult {loadfile confirm_overwrt} {
} else {
return "$fname"
}
} elseif { $type ne {SYMBOL} && ($myload_ext eq {*.sym}) } {
} elseif { $type ne {SYMBOL} && ($myload_ext eq {*.sym}) } { ;# SCHEMATIC
set answer [
alert_ "$fname does not seem to be a SYMBOL file...\nContinue?" {} 0 1]
if { $answer eq {0}} {
@ -2636,7 +2639,7 @@ proc myload_getresult {loadfile confirm_overwrt} {
} else {
return "$fname"
}
} else {
} else { ;# SYMBOL
return "$fname"
}
} else {
@ -2646,7 +2649,7 @@ proc myload_getresult {loadfile confirm_overwrt} {
proc myload_display_preview {f} {
set type [is_xschem_file $f]
if { $type ne {0} } {
if { $type ne {0} && $type ne {GENERATOR} } {
### update
if { [winfo exists .load] } {
.load.l.paneright.draw configure -background {}