fix crash on windows if a new tab is opened and immediately closed (incorrect call of draw() after clearing pixmap)

This commit is contained in:
stefan schippers 2023-07-07 08:30:13 +02:00
parent d06b1c83ae
commit 83071b4b21
2 changed files with 8 additions and 5 deletions

View File

@ -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);
}

View File

@ -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 */