preview_window: check xctx valid before calling resetwin()

This commit is contained in:
stefan schippers 2025-04-06 00:27:25 +02:00
parent 834d2c9757
commit 035794df47
2 changed files with 14 additions and 1 deletions

View File

@ -1267,7 +1267,7 @@ int preview_window(const char *what, const char *win_path, const char *fname)
dbg(1, "preview_window() draw, load schematic\n");
load_schematic(1,fname, 0, 1);
} else {
resetwin(1, 1, 0, 0, 0); /* resetwin(create_pixmap, clear_pixmap, force) */
if(xctx) resetwin(1, 1, 0, 0, 0); /* resetwin(create_pixmap, clear_pixmap, force) */
}
zoom_full(1, 0, 1 + 2 * tclgetboolvar("zoom_full_center"), 0.97); /* draw */
xctx = save_xctx;

View File

@ -8582,6 +8582,19 @@ global env has_x OS autofocus_mainwindow
bind $topwin <ButtonPress> "xschem callback %W %T %x %y 0 %b 0 %s"
}
bind $topwin <ButtonRelease> "xschem callback %W %T %x %y 0 %b 0 %s"
#### test: show keybindings
# bind $topwin <KeyPress-slash> "
# if {!\[info exists bindkeys\]} {
# set bindkeys 1
# xschem preview_window create $topwin
# xschem preview_window draw $topwin [abs_sym_path bindkeys_cheatsheet.sym]
# } else {
# unset bindkeys
# xschem preview_window $topwin close
# xschem redraw
# }
# "
bind $topwin <KeyPress> "
if {{%K} eq {Escape}} { destroy .ctxmenu }
xschem callback %W %T %x %y %N 0 0 %s"