# HG changeset patch # User sheepluva # Date 1418237041 -3600 # Node ID 90062f7a3103a81bea7847b8ebb6c95878322c71 # Parent 0be6442946b1f9ff30a7ad4bb8e8fc32f4735b3c merge FreeTexture into FreeAndNilTexture diff -r 0be6442946b1 -r 90062f7a3103 hedgewars/uTextures.pas --- a/hedgewars/uTextures.pas Wed Dec 10 08:05:45 2014 -0500 +++ b/hedgewars/uTextures.pas Wed Dec 10 19:44:01 2014 +0100 @@ -27,8 +27,7 @@ function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture; procedure PrettifySurfaceAlpha(surf: PSDL_Surface; pixels: PLongwordArray); procedure PrettifyAlpha2D(pixels: TLandArray; height, width: LongWord); -procedure FreeTexture(tex: PTexture); -procedure FreeAndNilTexture(var tex: PTexture); inline; +procedure FreeAndNilTexture(var tex: PTexture); procedure initModule; procedure freeModule; @@ -297,25 +296,20 @@ // deletes texture and frees the memory allocated for it. // if nil is passed nothing is done -procedure FreeTexture(tex: PTexture); +procedure FreeAndNilTexture(var tex: PTexture); begin -if tex <> nil then - begin - if tex^.NextTexture <> nil then - tex^.NextTexture^.PrevTexture:= tex^.PrevTexture; - if tex^.PrevTexture <> nil then - tex^.PrevTexture^.NextTexture:= tex^.NextTexture - else - TextureList:= tex^.NextTexture; - glDeleteTextures(1, @tex^.id); - Dispose(tex); - end -end; - -procedure FreeAndNilTexture(var tex: PTexture); inline; -begin - FreeTexture(tex); - tex:= nil + if tex <> nil then + begin + if tex^.NextTexture <> nil then + tex^.NextTexture^.PrevTexture:= tex^.PrevTexture; + if tex^.PrevTexture <> nil then + tex^.PrevTexture^.NextTexture:= tex^.NextTexture + else + TextureList:= tex^.NextTexture; + glDeleteTextures(1, @tex^.id); + Dispose(tex); + tex:= nil; + end; end; procedure initModule; @@ -324,13 +318,15 @@ end; procedure freeModule; +var tex: PTexture; begin if TextureList <> nil then WriteToConsole('FIXME FIXME FIXME. App shutdown without full cleanup of texture list; read game0.log and please report this problem'); while TextureList <> nil do begin - AddFileLog('Texture not freed: width='+inttostr(LongInt(TextureList^.w))+' height='+inttostr(LongInt(TextureList^.h))+' priority='+inttostr(round(TextureList^.priority*1000))); - FreeTexture(TextureList); + tex:= TextureList; + AddFileLog('Texture not freed: width='+inttostr(LongInt(tex^.w))+' height='+inttostr(LongInt(tex^.h))+' priority='+inttostr(round(tex^.priority*1000))); + FreeAndNilTexture(tex); end end;