From: DeaDDooMER Date: Wed, 20 Feb 2019 19:51:20 +0000 (+0300) Subject: Try to fix file deletion X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-editor.git;a=commitdiff_plain;h=b9e48f22d4c3357a3f14c47a4ec7151d811e9a12 Try to fix file deletion --- diff --git a/src/editor/g_resources.pas b/src/editor/g_resources.pas index cc8e0a8..bcb7da2 100644 --- a/src/editor/g_resources.pas +++ b/src/editor/g_resources.pas @@ -100,20 +100,23 @@ implementation procedure g_DeleteFile (wad: String; backupPostfix: String = '.bak'); var newwad: String; begin + SFSGCCollect; + SFSGCCollect; + SFSGCCollect; if Backup then begin if FileExists(wad) then begin newwad := wad + backupPostfix; if FileExists(newwad) then - ASSERT(DeleteFile(newwad)); - ASSERT(RenameFile(wad, newwad)) + ASSERT(DeleteFile(newwad), 'Can''t delete file ' + newwad); + ASSERT(RenameFile(wad, newwad), 'Can''t rename file ' + wad + ' -> ' + newwad) end end else begin if FileExists(wad) then - ASSERT(DeleteFile(wad)) + ASSERT(DeleteFile(wad), 'Can''t delete file ' + newwad) end end; @@ -198,7 +201,7 @@ implementation ts.Free; g_DeleteFile(wad); - ASSERT(RenameFile(tmp, wad)); + ASSERT(RenameFile(tmp, wad), 'Can''t rename file ' + tmp + ' -> ' + wad); res := 0 end; @@ -290,7 +293,7 @@ implementation ts.Free; g_DeleteFile(wad); - ASSERT(RenameFile(tmp, wad)); + ASSERT(RenameFile(tmp, wad), 'Can''t rename file ' + tmp + ' -> ' + wad); res := 0 end; @@ -385,12 +388,17 @@ implementation for i := 0 to len - 1 do data[i] := stream1.ReadByte(); stream1.Destroy + //stream0.Destroy (* leads to memory corruption, it destroyed with stream1? *) + end + else + begin + stream0.Destroy end end - end - else - begin - stream0.Destroy + else + begin + stream0.Destroy + end end end; SFSGCCollect