From 88e7f4fea419cd5edc6a68ee74cc6c2885778dca Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 4 Nov 2023 22:50:57 +0100 Subject: [PATCH] fix a problem in set_modify() (inconsistent prev_set_modify state after netlist of modified circuit) --- src/actions.c | 31 ++++++++++++++++++++----------- src/spice_netlist.c | 4 ++++ src/tedax_netlist.c | 2 ++ src/verilog_netlist.c | 2 ++ src/vhdl_netlist.c | 2 ++ 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/actions.c b/src/actions.c index deb0ddb5..d63958e2 100644 --- a/src/actions.c +++ b/src/actions.c @@ -142,11 +142,16 @@ int set_modify(int mod) { int i, floaters = 0; - if(mod != -2 && mod != -1) xctx->modified = mod; - dbg(1, "set_modify(): %d\n", mod); + dbg(1, "set_modify(): %d, prev_set_modify=%d\n", mod, xctx->prev_set_modify); - if(mod == 1 || mod == -1 || mod == -2) { - /* hash instance names if there are (many) floaters and many instances for faster lookup */ + /* set modify state */ + if(mod == 0 || mod == 1) { + xctx->prev_set_modify = xctx->modified; + xctx->modified = mod; + } + + /* clear floater caches */ + if(mod == 1 || mod == -2) { for(i = 0; i < xctx->texts; i++) if(xctx->text[i].flags & TEXT_FLOATER) { floaters++; @@ -154,21 +159,24 @@ int set_modify(int mod) } int_hash_free(&xctx->floater_inst_table); } - if(mod != -2 && (mod == -1 || mod != xctx->prev_set_modify) ) { /* mod=-1 used to force set title */ - if(mod != -1) xctx->prev_set_modify = mod; - else mod = xctx->modified; - if(has_x && strcmp(get_cell(xctx->sch[xctx->currsch],1), "systemlib/font")) { + + /* force title no mod mod */ + if(mod == -1 || mod == 0 || mod == 1) { + if(has_x && + strcmp(get_cell(xctx->sch[xctx->currsch],1), "systemlib/font") && + (xctx->prev_set_modify != xctx->modified || mod == -1) + ) { char *top_path = xctx->top_path[0] ? xctx->top_path : "."; - if(mod == 1) { + if(xctx->modified == 1) { tclvareval("wm title ", top_path, " \"xschem - [file tail [xschem get schname]]*\"", NULL); tclvareval("wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]*\"", NULL); } else { tclvareval("wm title ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL); tclvareval("wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL); } + if(xctx->modified) tcleval("set_tab_names *"); + else tcleval("set_tab_names"); } - if(xctx->modified) tcleval("set_tab_names *"); - else tcleval("set_tab_names"); } return floaters; } @@ -481,6 +489,7 @@ int save(int confirm) if(force || xctx->modified) { + dbg(1, "save(): force=%d modified=%d\n", force, xctx->modified); if(confirm) { tcleval("ask_save_optional"); if(!strcmp(tclresult(), "") ) return -1; /* user clicks "Cancel" */ diff --git a/src/spice_netlist.c b/src/spice_netlist.c index c25424ce..6f8ee133 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -51,6 +51,7 @@ void hier_psprint(char **res, int what) /* netlister driver */ char *abs_path = NULL; struct stat buf; Str_hashtable subckt_table = {NULL, 0}; + int save_prev_mod = xctx->prev_set_modify; save = xctx->do_copy_area; xctx->do_copy_area = 0; @@ -120,6 +121,7 @@ void hier_psprint(char **res, int what) /* netlister driver */ xctx->currsch--; unselect_all(1); xctx->pop_undo(4, 0); + xctx->prev_set_modify = save_prev_mod; my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name)); xctx->do_copy_area = save; if(what & 1) ps_draw(4, 1); /* trailer */ @@ -242,6 +244,7 @@ int global_spice_netlist(int global) /* netlister driver */ Str_hashtable subckt_table = {NULL, 0}; Str_hashentry *model_entry; int lvs_ignore = tclgetboolvar("lvs_ignore"); + int save_prev_mod = xctx->prev_set_modify; split_f = tclgetboolvar("split_files"); dbg(1, "global_spice_netlist(): invoking push_undo()\n"); @@ -436,6 +439,7 @@ int global_spice_netlist(int global) /* netlister driver */ unselect_all(1); dbg(1, "global_spice_netlist(): invoking pop_undo(0, 0)\n"); xctx->pop_undo(4, 0); + xctx->prev_set_modify = save_prev_mod; if(web_url) { my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname)); } else { diff --git a/src/tedax_netlist.c b/src/tedax_netlist.c index 4532adf0..c85b9ab7 100644 --- a/src/tedax_netlist.c +++ b/src/tedax_netlist.c @@ -129,6 +129,7 @@ int global_tedax_netlist(int global) /* netlister driver */ char *abs_path = NULL; Str_hashtable subckt_table = {NULL, 0}; int lvs_ignore = tclgetboolvar("lvs_ignore"); + int save_prev_mod = xctx->prev_set_modify; xctx->push_undo(); statusmsg("",2); /* clear infowindow */ @@ -234,6 +235,7 @@ int global_tedax_netlist(int global) /* netlister driver */ xctx->currsch--; unselect_all(1); xctx->pop_undo(4, 0); + xctx->prev_set_modify = save_prev_mod; if(web_url) { my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname)); } else { diff --git a/src/verilog_netlist.c b/src/verilog_netlist.c index 526e4b8d..4d08377e 100644 --- a/src/verilog_netlist.c +++ b/src/verilog_netlist.c @@ -96,6 +96,7 @@ int global_verilog_netlist(int global) /* netlister driver */ const char *fmt_attr = NULL; Str_hashtable subckt_table = {NULL, 0}; int lvs_ignore = tclgetboolvar("lvs_ignore"); + int save_prev_mod = xctx->prev_set_modify; split_f = tclgetboolvar("split_files"); xctx->push_undo(); @@ -361,6 +362,7 @@ int global_verilog_netlist(int global) /* netlister driver */ xctx->currsch--; unselect_all(1); xctx->pop_undo(4, 0); + xctx->prev_set_modify = save_prev_mod; if(web_url) { my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname)); } else { diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 9f5c6057..8183938b 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -121,6 +121,7 @@ int global_vhdl_netlist(int global) /* netlister driver */ int split_f; Str_hashtable subckt_table = {NULL, 0}; int lvs_ignore = tclgetboolvar("lvs_ignore"); + int save_prev_mod = xctx->prev_set_modify; split_f = tclgetboolvar("split_files"); xctx->push_undo(); @@ -450,6 +451,7 @@ int global_vhdl_netlist(int global) /* netlister driver */ xctx->currsch--; unselect_all(1); xctx->pop_undo(4, 0); + xctx->prev_set_modify = save_prev_mod; if(web_url) { my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname)); } else {