Engine:
authorsmxx
Wed, 10 Feb 2010 17:31:12 +0000
changeset 2796 7f86e7ad378b
parent 2795 c9c830897547
child 2797 98b990feec7d
Engine: * Proper cleanup after creating landscape preview * Avoid trying to write to current working directory (no-go under Windows Vista/7 if installed to C:\Program Files)
hedgewars/hwengine.pas
hedgewars/uAmmos.pas
hedgewars/uMisc.pas
hedgewars/uTeams.pas
--- a/hedgewars/hwengine.pas	Wed Feb 10 17:15:10 2010 +0000
+++ b/hedgewars/hwengine.pas	Wed Feb 10 17:31:12 2010 +0000
@@ -166,7 +166,9 @@
 	TTF_Quit();
 	{$IFDEF SDL13}SDL_VideoQuit();{$ENDIF}
 	SDL_Quit();
+	{$IFDEF IPHONEOS}
 	freeEverything();
+	{$ENDIF}
 	exit();
 end;
 
@@ -578,6 +580,7 @@
 
 	if GameType = gmtLandPreview then GenLandPreview()
 	else Game();
+	freeEverything();
 	ExitCode:= 0;
 {$ENDIF}
 end.
--- a/hedgewars/uAmmos.pas	Wed Feb 10 17:15:10 2010 +0000
+++ b/hedgewars/uAmmos.pas	Wed Feb 10 17:31:12 2010 +0000
@@ -372,7 +372,8 @@
 procedure free_uAmmos;
 var i: LongWord;
 begin
-	for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]);
+	if StoreCnt > 0 then
+		for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]);
 	StoreCnt:= 0
 end;
 
--- a/hedgewars/uMisc.pas	Wed Feb 10 17:15:10 2010 +0000
+++ b/hedgewars/uMisc.pas	Wed Feb 10 17:31:12 2010 +0000
@@ -740,15 +740,9 @@
 	begin
 		assign(f, ParamStr(1) + '/debug' + inttostr(i) + '.txt');
 		rewrite(f);
-		if IOResult = 5 then
-		begin
-			// prevent writing on a directory you do not have permissions on
-			// should be safe to assume the current directory is writable
-			assign(f, './debug' + inttostr(i) + '.txt');
-			rewrite(f);
-		end;
 		if IOResult = 0 then break;
 	end;
+	if IOResult <> 0 then f:= stderr; // if everything fails, write to stderr
 {$ENDIF}
 {$I+}
 {$ENDIF}
--- a/hedgewars/uTeams.pas	Wed Feb 10 17:15:10 2010 +0000
+++ b/hedgewars/uTeams.pas	Wed Feb 10 17:31:12 2010 +0000
@@ -466,8 +466,11 @@
 procedure free_uTeams;
 var i: LongWord;
 begin
-   for i:= 0 to Pred(TeamsCount) do Dispose(TeamsArray[i]);
-   for i:= 0 to Pred(ClansCount) do Dispose(ClansArray[i]);
+   if TeamsCount > 0 then
+     begin
+     for i:= 0 to Pred(TeamsCount) do Dispose(TeamsArray[i]);
+     for i:= 0 to Pred(ClansCount) do Dispose(ClansArray[i]);
+     end;
    TeamsCount:= 0;
    ClansCount:= 0
 end;