fix web hierarchy navigation error when returning to web schematic after descending into a local symbol

This commit is contained in:
stefan schippers 2023-03-13 11:11:43 +01:00
parent 6e13f3cd77
commit 6d192023de
7 changed files with 21 additions and 55 deletions

View File

@ -1224,6 +1224,19 @@ void get_sch_from_sym(char *filename, xSymbol *sym)
else my_strncpy(filename, add_ext(abs_sym_path(sym->name, ""), ".sch"), PATH_MAX);
}
}
/* if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
* strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
*/
if(web_url) {
char sympath[PATH_MAX];
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
/* build local file name of downloaded object and load it */
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
my_strncpy(filename, sympath, PATH_MAX);
}
my_free(_ALLOC_ID_, &str_tmp);
dbg(1, "get_sch_from_sym(): sym->name=%s, filename=%s\n", sym->name, filename);
}
@ -1343,18 +1356,9 @@ int descend_schematic(int instnumber)
unselect_all(1);
get_sch_from_sym(filename, xctx->inst[n].ptr+ xctx->sym);
remove_symbols();
dbg(1, "descend_schematic(): filename=%s\n", filename);
/* we are descending from a parent schematic downloaded from the web */
if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
char sympath[PATH_MAX];
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
/* build local file name of downloaded object and load it */
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
my_strncpy(filename, sympath, S(filename));
}
remove_symbols();
load_schematic(1, filename, 1);
if(xctx->hilight_nets)
{

View File

@ -2430,7 +2430,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo) /* 2015
/* build local file name of downloaded object */
my_snprintf(name, S(name), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(fname, 0));
/* build current_dirname by stripping off last filename from url */
my_snprintf(msg, S(msg), "regsub {/\\.$} [get_directory {%s}] {}", fname);
my_snprintf(msg, S(msg), "get_directory {%s}", fname);
my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname));
/* local file name */
my_strncpy(xctx->sch[xctx->currsch], name, S(xctx->sch[xctx->currsch]));
@ -2443,8 +2443,9 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo) /* 2015
/* ... but not local file from web download --> reset current_dirname */
char sympath[PATH_MAX];
my_snprintf(sympath, S(sympath), "%s/xschem_web", tclgetvar("XSCHEM_TMP_DIR"));
if(strstr(fname, sympath) != fname) {
my_snprintf(msg, S(msg), "regsub {/\\.$} [get_directory {%s}] {}", fname);
/* fname does not begin with $XSCHEM_TMP_DIR/xschem_web and fname does not exist */
if(strstr(fname, sympath) != fname && stat(fname, &buf)) {
my_snprintf(msg, S(msg), "get_directory {%s}", fname);
my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname));
}
/* local file name */
@ -2454,7 +2455,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo) /* 2015
/* local file specified and not coming from web url */
} else {
/* if name is /some/path/. remove /. at end */
my_snprintf(msg, S(msg), "regsub {/\\.$} [get_directory {%s}] {}", fname);
my_snprintf(msg, S(msg), "get_directory {%s}", fname);
my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname));
/* local file name */
my_strncpy(xctx->sch[xctx->currsch], fname, S(xctx->sch[xctx->currsch]));
@ -2503,7 +2504,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo) /* 2015
}
}
dbg(1, "load_schematic(): %s, returning\n", xctx->sch[xctx->currsch]);
} else {
} else { /* fname == NULL or empty */
/* if(reset_undo) xctx->time_last_modify = time(NULL); */ /* no file given, set mtime to current time */
if(reset_undo) xctx->time_last_modify = 0; /* no file given, set mtime to 0 (undefined) */
clear_drawing();

View File

@ -529,16 +529,6 @@ void spice_block_netlist(FILE *fd, int i)
spice_stop=0;
get_sch_from_sym(filename, xctx->sym + i);
if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
char sympath[PATH_MAX];
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
/* build local file name of downloaded object and load it */
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
my_strncpy(filename, sympath, S(filename));
}
if(split_f) {
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d",
tclgetvar("netlist_dir"), skip_dir(xctx->sym[i].name), getpid());

View File

@ -85,16 +85,6 @@ static void tedax_block_netlist(FILE *fd, int i)
tedax_stop=0;
get_sch_from_sym(filename, xctx->sym + i);
if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
char sympath[PATH_MAX];
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
/* build local file name of downloaded object and load it */
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
my_strncpy(filename, sympath, S(filename));
}
fprintf(fd, "\n# expanding symbol: %s # of pins=%d\n",
xctx->sym[i].name,xctx->sym[i].rects[PINLAYER] );
fprintf(fd, "## sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));

View File

@ -437,16 +437,6 @@ void verilog_block_netlist(FILE *fd, int i)
verilog_stop=0;
get_sch_from_sym(filename, xctx->sym + i);
if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
char sympath[PATH_MAX];
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
/* build local file name of downloaded object and load it */
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
my_strncpy(filename, sympath, S(filename));
}
if(split_f) {
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d",
tclgetvar("netlist_dir"), skip_dir(xctx->sym[i].name), getpid());

View File

@ -529,16 +529,6 @@ void vhdl_block_netlist(FILE *fd, int i)
vhdl_stop=0;
get_sch_from_sym(filename, xctx->sym + i);
if( strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname) {
char sympath[PATH_MAX];
/* download item into ${XSCHEM_TMP_DIR}/xschem_web */
tclvareval("try_download_url {", xctx->current_dirname, "} {", filename, "}", NULL);
/* build local file name of downloaded object and load it */
my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(filename, 0));
my_strncpy(filename, sympath, S(filename));
}
if(split_f) {
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d",
tclgetvar("netlist_dir"), skip_dir(xctx->sym[i].name), getpid());

View File

@ -4506,6 +4506,7 @@ proc get_directory {f} {
} else {
set r [regsub {/[^/]*$} $f {}]
}
regsub {/\.$} $r {} r
return $r
}