clean up fonts
authorsheepluva
Mon, 08 Dec 2014 17:43:27 +0100
changeset 10640 efa069762cb2
parent 10639 992863acb2b7
child 10641 802589828f99
clean up fonts
hedgewars/SDLh.pas
hedgewars/uStore.pas
--- a/hedgewars/SDLh.pas	Mon Dec 08 11:20:31 2014 -0500
+++ b/hedgewars/SDLh.pas	Mon Dec 08 17:43:27 2014 +0100
@@ -1105,6 +1105,7 @@
 
 function  TTF_OpenFontRW(src: PSDL_RWops; freesrc: LongBool; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
+procedure TTF_CloseFont(font: PTTF_Font); cdecl; external SDL_TTFLibName;
 
 (*  SDL_mixer  *)
 function  Mix_Init(flags: LongInt): LongInt; {$IFDEF SDL_MIXER_NEWER}cdecl; external SDL_MixerLibName{$ELSE}inline{$ENDIF};
--- a/hedgewars/uStore.pas	Mon Dec 08 11:20:31 2014 -0500
+++ b/hedgewars/uStore.pas	Mon Dec 08 17:43:27 2014 +0100
@@ -1257,8 +1257,20 @@
 end;
 
 procedure freeModule;
+var fi: THWFont;
 begin
     StoreRelease(false);
+    // make sure fonts are cleaned up
+    for fi:= Low(THWFont) to High(THWFont) do
+        with Fontz[fi] do
+            begin
+            if Handle <> nil then
+                begin
+                TTF_CloseFont(Handle);
+                Handle:= nil;
+                end;
+            end;
+
     TTF_Quit();
 {$IFDEF SDL2}
     SDL_GL_DeleteContext(SDLGLcontext);