From 7be39c651ea95f2953c46396c3093eb119d338ef Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 6 Feb 2015 05:21:39 +0000 Subject: [PATCH] TexMgr_ReloadImages: put in a workaround for the bug reported by Steven where fullscreen toggle on jam3_tronyn.bsp with -heapsize 65536 causes corrupted textures git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1162 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/gl_texmgr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Quake/gl_texmgr.c b/Quake/gl_texmgr.c index f92af8cb..200bdc96 100644 --- a/Quake/gl_texmgr.c +++ b/Quake/gl_texmgr.c @@ -1389,6 +1389,13 @@ void TexMgr_ReloadImages (void) { gltexture_t *glt; +// ericw -- flush the cache before reloading textures. This avoids an obscure +// bug where, if the hunk is almost full, an allocation in TexMgr_ReloadImage +// triggers cache items to be freed, which calls back into TexMgr to free the +// texture. Calling TexMgr_FreeTexture within the loop below causes things to +// go haywire. A test case is jam3_tronyn.bsp with -heapsize 65536 + Cache_Flush(); + for (glt = active_gltextures; glt; glt = glt->next) { glGenTextures(1, &glt->texnum);