From 83071b4b212641423a74ce6f5f10ac649b91820a Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 7 Jul 2023 08:30:13 +0200 Subject: [PATCH] fix crash on windows if a new tab is opened and immediately closed (incorrect call of draw() after clearing pixmap) --- src/draw.c | 8 +++++--- src/xinit.c | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/draw.c b/src/draw.c index a07fe9e3..a935efb6 100644 --- a/src/draw.c +++ b/src/draw.c @@ -3648,9 +3648,10 @@ void draw(void) if(tclgetboolvar("dark_colorscheme")) build_colors(-1.5, 0); else build_colors(1.5, 0); } - if(xctx->draw_pixmap) + if(xctx->draw_pixmap) { XFillRectangle(display, xctx->save_pixmap, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1, xctx->areaw, xctx->areah); + } if(xctx->draw_window) XFillRectangle(display, xctx->window, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1, xctx->areaw, xctx->areah); @@ -3812,8 +3813,9 @@ void draw(void) xctx->lw = xctx->save_lw; change_linewidth(xctx->save_lw); } - if(xctx->do_copy_area) { /* this is zero only when doing png hardcopy to avoid video flickering */ - if(!xctx->draw_window) { + /* do_copy_area is zero only when doing png hardcopy to avoid video flickering */ + if(xctx->do_copy_area) { + if(!xctx->draw_window && xctx->save_pixmap) { MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y); } diff --git a/src/xinit.c b/src/xinit.c index 85f7b37f..ff185975 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1644,7 +1644,7 @@ static void create_new_tab(int *window_count, const char *noconfirm, const char xctx->yorigin=CADINITIALY; load_schematic(1,fname, 1, 1); zoom_full(1, 0, 1 + 2 * tclgetboolvar("zoom_full_center"), 0.97); /* draw */ - xctx->pending_fullzoom=1; + /* xctx->pending_fullzoom=1; */ } static void destroy_window(int *window_count, const char *win_path) @@ -2080,6 +2080,7 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h) #else Tk_FreePixmap(display, xctx->save_pixmap); #endif + xctx->save_pixmap = 0; XFreeGC(display,xctx->gctiled); } if(create_pixmap) { @@ -2099,7 +2100,7 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h) } } } - if(xctx->pending_fullzoom > 0) { + if(xctx->pending_fullzoom > 0 && create_pixmap) { tcleval("winfo ismapped ."); /* if window unmapped or size has not been set by wm (width == 1 // height == 1) do not * perform the pending full_zoom */