From eff146e56bd5e47d0f20af245a00262e86c9f59f Mon Sep 17 00:00:00 2001 From: ennewalker Date: Fri, 18 Apr 2008 21:38:35 +0000 Subject: [1941577] Fix for crashes when resizing screen. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4346 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/guic-x11.cc | 3 ++- crawl-ref/source/tile2.cc | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/guic-x11.cc b/crawl-ref/source/guic-x11.cc index a1eedf0629..54027f0353 100644 --- a/crawl-ref/source/guic-x11.cc +++ b/crawl-ref/source/guic-x11.cc @@ -392,7 +392,8 @@ void ImgSetTransparentPix(img_type img) void ImgDestroy(img_type img) { - XDestroyImage(img); + if (img) + XDestroyImage(img); } img_type ImgCreateSimple(int wx, int wy) diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc index 800998a040..a2522d2f6f 100644 --- a/crawl-ref/source/tile2.cc +++ b/crawl-ref/source/tile2.cc @@ -137,7 +137,7 @@ int get_floor_special_tile_idx() static int last_cursor = -1; //Internal cache Image buffer -static img_type tcache_image; +static img_type tcache_image = 0; //Start of a pointer string static int tcache_head; @@ -322,19 +322,18 @@ void TileResizeScreen(int x0, int y0) { tile_xmax = x0; tile_ymax = y0; -#if 0 max_tcache = 4*tile_xmax*tile_ymax; free(screen_tcache_idx); screen_tcache_idx = (int *)malloc(sizeof(int)* tile_xmax * tile_ymax); - free(tcache[k]); - tcache[k] = (tile_cache *)malloc(sizeof(tile_cache)*max_tcache); + free(tcache); + tcache = (tile_cache *)malloc(sizeof(tile_cache)*max_tcache); for (int x = 0; x < tile_xmax * tile_ymax; x++) screen_tcache_idx[x] = -1; - _clear_tcache(); -#endif + _init_tcache(); + crawl_view.viewsz.x = tile_xmax; crawl_view.viewsz.y = tile_ymax; crawl_view.vbuf.size(crawl_view.viewsz); @@ -363,6 +362,7 @@ void _clear_tcache() void _init_tcache() { _clear_tcache(); + ImgDestroy(tcache_image); tcache_image = ImgCreateSimple(tcache_wx_normal, max_tcache*tcache_wy_normal); } -- cgit v1.2.3-54-g00ecf