From 2b94e845c09bf1c7697e2cc1d1f7cfb6d2fbe67e Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 31 Aug 2024 08:07:17 +0200 Subject: [PATCH] fix a bug in preview symbol displaying when inserting components. Toplevel .load widget was destroyed before cleaning preview data in preview_window(), so after some insertion preview was no more displayed. --- src/xinit.c | 8 ++++++-- src/xschem.tcl | 14 +++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/xinit.c b/src/xinit.c index e45281ac..320f5855 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1197,6 +1197,8 @@ int preview_window(const char *what, const char *win_path, const char *fname) * and an Expose event calls another preview draw */ if(semaphore) return 0; ++semaphore; + dbg(1, "preview_window(): what=%s, win_path=%s, fname=%s\n", + what, win_path ? win_path : "NULL", fname ? fname : "NULL"); dbg(1, "------\n"); tclvareval("save_ctx ", xctx->current_win_path, NULL); if(!strcmp(what, "create") && last_preview < 4) { @@ -1206,6 +1208,7 @@ int preview_window(const char *what, const char *win_path, const char *fname) for(i = 0; i < 10; i++) { if(tkpre_window[i] == NULL) break; } + dbg(1, "preview_window(): create slot %d\n", i); if(i < 10) { tkpre_window[i] = Tk_NameToWindow(interp, win_path, mainwindow); if(tkpre_window[i]) { @@ -1217,10 +1220,10 @@ int preview_window(const char *what, const char *win_path, const char *fname) } else if(!strcmp(what, "draw") ) { int i; - dbg(1, "preview_window() draw\n"); for(i = 0; i < 10; i++) { if(Tk_NameToWindow(interp, win_path, mainwindow) == tkpre_window[i] && tkpre_window[i]) break; } + dbg(1, "preview_window(): draw slot %d\n", i); if(i < 10) { save_xctx = xctx; /* save current schematic */ xctx = preview_xctx[i]; @@ -1252,8 +1255,9 @@ int preview_window(const char *what, const char *win_path, const char *fname) int i; dbg(1, "preview_window(): %s\n", what); for(i = 0; i < 10; i++) { - if(Tk_NameToWindow(interp, win_path, mainwindow) == tkpre_window[i]) break; + if(Tk_NameToWindow(interp, win_path, mainwindow) == tkpre_window[i] && tkpre_window[i]) break; } + dbg(1, "preview_window(): destroy slot %d\n", i); if(i < 10) { if(preview_xctx[i]) { save_xctx = xctx; /* save current schematic */ diff --git a/src/xschem.tcl b/src/xschem.tcl index 0e66b7fe..81aa55a5 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -3853,15 +3853,15 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} frame .load.buttons_bot -takefocus 0 button .load.buttons_bot.ok -width 5 -text OK -takefocus 0 -command " set file_dialog_retval \[.load.buttons_bot.entry get\] + xschem preview_window destroy .load.l.paneright.draw {} destroy .load - xschem preview_window destroy {} {} set $global_initdir \"\$file_dialog_dir1\" " button .load.buttons_bot.cancel -width 5 -text Cancel -takefocus 0 -command " set file_dialog_retval {} - destroy .load if {\$file_dialog_loadfile == 2} {xschem abort_operation} - xschem preview_window destroy {} {} + xschem preview_window destroy .load.l.paneright.draw {} + destroy .load set $global_initdir \"\$file_dialog_dir1\" " wm protocol .load WM_DELETE_WINDOW {.load.buttons_bot.cancel invoke} @@ -3978,8 +3978,8 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} if {\$file_dialog_retval ne {} && !\[file isdirectory \$file_dialog_retval\]} { bind .load.l.paneright.draw {} bind .load.l.paneright.draw {} + xschem preview_window destroy .load.l.paneright.draw {} destroy .load - xschem preview_window destroy {} {} set $global_initdir \"\$file_dialog_dir1\" } " @@ -3988,17 +3988,17 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} if {\$file_dialog_retval ne {} && !\[file isdirectory \$file_dialog_retval\]} { bind .load.l.paneright.draw {} bind .load.l.paneright.draw {} + xschem preview_window destroy .load.l.paneright.draw {} destroy .load - xschem preview_window destroy {} {} set $global_initdir \"\$file_dialog_dir1\" } " } bind .load " set file_dialog_retval {} - destroy .load if {\$file_dialog_loadfile == 2} {xschem abort_operation} - xschem preview_window destroy {} {} + xschem preview_window destroy .load.l.paneright.draw {} + destroy .load set $global_initdir \"\$file_dialog_dir1\" "