- Actually call uTexture.initModule and .freeModule
authorunc0rr
Fri, 27 Sep 2013 12:58:21 +0400
changeset 9468 3d07fd84c39d
parent 9466 8b48c27201af
child 9470 9ed07a96349d
- Actually call uTexture.initModule and .freeModule - Fix texture leaks in teams/hedgehogs structures on application shutdown
hedgewars/hwengine.pas
hedgewars/uTeams.pas
--- a/hedgewars/hwengine.pas	Fri Sep 27 00:54:18 2013 +0400
+++ b/hedgewars/hwengine.pas	Fri Sep 27 12:58:21 2013 +0400
@@ -32,7 +32,7 @@
 uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler
      , uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uAILandMarks, uLandTexture, uCollisions
      , SysUtils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted
-     , uPhysFSLayer, uCursor, uRandom, ArgParsers, uVisualGearsHandlers
+     , uPhysFSLayer, uCursor, uRandom, ArgParsers, uVisualGearsHandlers, uTextures
      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}
      {$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF}
      {$IFDEF ANDROID}, GLUnit{$ENDIF}
@@ -441,6 +441,7 @@
     if complete then
     begin
         uPhysFSLayer.initModule;
+        uTextures.initModule;
 {$IFDEF ANDROID}GLUnit.initModule;{$ENDIF}
 {$IFDEF USE_TOUCH_INTERFACE}uTouch.initModule;{$ENDIF}
 {$IFDEF USE_VIDEO_RECORDING}uVideoRec.initModule;{$ENDIF}   //stub
@@ -493,6 +494,7 @@
 {$IFDEF USE_VIDEO_RECORDING}uVideoRec.freeModule;{$ENDIF}
 {$IFDEF USE_TOUCH_INTERFACE}uTouch.freeModule;{$ENDIF}  //stub
 {$IFDEF ANDROID}GLUnit.freeModule;{$ENDIF}
+        uTextures.freeModule;
         uPhysFSLayer.freeModule;
     end;
 
--- a/hedgewars/uTeams.pas	Fri Sep 27 00:54:18 2013 +0400
+++ b/hedgewars/uTeams.pas	Fri Sep 27 12:58:21 2013 +0400
@@ -43,7 +43,7 @@
 
 implementation
 uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug,
-    uGearsUtils, uGearsList, uVisualGearsList
+    uGearsUtils, uGearsList, uVisualGearsList, uTextures
     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
 
 var MaxTeamHealth: LongInt;
@@ -714,8 +714,26 @@
     for i:= 0 to Pred(TeamsCount) do
         begin
         for h:= 0 to cMaxHHIndex do
-            if TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil then
-                Dispose(TeamsArray[i]^.Hedgehogs[h].GearHidden);
+            with TeamsArray[i]^.Hedgehogs[h] do
+                begin
+                if GearHidden <> nil then
+                    Dispose(GearHidden);
+                    
+                FreeTexture(NameTagTex);
+                FreeTexture(HealthTagTex);
+                FreeTexture(HatTex);
+                end;
+                
+        with TeamsArray[i]^ do
+            begin
+            FreeTexture(NameTagTex);
+            FreeTexture(CrosshairTex);
+            FreeTexture(GraveTex);
+            FreeTexture(HealthTex);
+            FreeTexture(AIKillsTex);
+            FreeTexture(FlagTex);
+            end;
+        
         Dispose(TeamsArray[i]);
     end;
 for i:= 0 to Pred(ClansCount) do