Changeset 290


Ignore:
Timestamp:
Feb 26, 2021, 11:56:48 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Use FreeAndNil instead of Free as defensive measure.
  • Modified: Use ihnerited without same method name specification.
Location:
trunk
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/CmdList.pas

    r38 r290  
    5757constructor TCmdList.Create;
    5858begin
    59   inherited Create;
     59  inherited;
    6060  FState.nLog := 0;
    6161  LogAlloc := 0;
     
    6969begin
    7070  ReallocMem(LogData, 0);
    71   inherited Destroy;
     71  inherited;
    7272end;
    7373
  • trunk/Database.pas

    r227 r290  
    10821082    else
    10831083      result := 0;
    1084     Q.Free;
     1084    FreeAndNil(Q);
    10851085  end;
    10861086
  • trunk/GameServer.pas

    r288 r290  
    77
    88uses
    9   Protocol, Database, dynlibs, Platform, dateutils, fgl, LazFileUtils, Graphics;
     9  Protocol, Database, dynlibs, Platform, dateutils, fgl, LazFileUtils,
     10  Graphics;
    1011
    1112const
     
    289290        FreeLibrary(hm);
    290291    end;
    291   PlayersBrain.Free;
    292   bix.Free;
    293   Brains.Free;
     292  FreeAndNil(PlayersBrain);
     293  FreeAndNil(bix);
     294  FreeAndNil(Brains);
    294295end;
    295296
     
    561562  MapFile := TFileStream.Create(GetMapsDir + DirectorySeparator + FileName,
    562563    fmCreate or fmShareExclusive);
    563   MapFile.Position := 0;
    564   s := 'cEvoMap'#0;
    565   MapFile.write(s[1], 8); { file id }
    566   i := 0;
    567   MapFile.write(i, 4); { format id }
    568   MapFile.write(MaxTurn, 4);
    569   MapFile.write(lx, 4);
    570   MapFile.write(ly, 4);
    571   MapFile.write(RealMap, MapSize * 4);
    572   MapFile.Free;
     564  try
     565    MapFile.Position := 0;
     566    s := 'cEvoMap'#0;
     567    MapFile.write(s[1], 8); { file id }
     568    i := 0;
     569    MapFile.write(i, 4); { format id }
     570    MapFile.write(MaxTurn, 4);
     571    MapFile.write(lx, 4);
     572    MapFile.write(ly, 4);
     573    MapFile.write(RealMap, MapSize * 4);
     574  finally
     575    FreeAndNil(MapFile);
     576  end;
    573577end;
    574578
     
    613617      result := true;
    614618    end;
    615     MapFile.Free;
     619    FreeAndNil(MapFile);
    616620  except
    617621    if MapFile <> nil then
    618       MapFile.Free;
     622      FreeAndNil(MapFile);
    619623  end;
    620624end;
     
    694698  else
    695699    CL.SaveToFile(LogFile);
    696   LogFile.Free;
     700  FreeAndNil(LogFile);
    697701  if auto then
    698702  begin
     
    721725        Brains.GetByKind(btAI, AIBrains);
    722726        bix[p1] := AIBrains[DelphiRandom(AIBrains.Count)];
    723         AIBrains.Free;
     727        FreeAndNil(AIBrains);
    724728      end
    725729    else
     
    992996  CityProcessing.ReleaseGame;
    993997  Database.ReleaseGame;
    994   CL.Free;
     998  FreeAndNil(CL);
    995999end;
    9961000
     
    11901194    CL.LoadFromFile(LogFile);
    11911195  end;
    1192   LogFile.Free;
     1196  FreeAndNil(LogFile);
    11931197  if not result then
    11941198    Exit;
     
    46044608begin
    46054609  FreeAndNil(Picture);
    4606   inherited Destroy;
     4610  inherited;
    46074611end;
    46084612
  • trunk/IPQ.pas

    r38 r290  
    4747  GetMem(Ix, fmax * sizeof(integer));
    4848  n := -1;
    49   Empty
     49  Empty;
    5050end;
    5151
     
    5454  FreeMem(bh);
    5555  FreeMem(Ix);
    56   inherited Destroy;
     56  inherited;
    5757end;
    5858
  • trunk/LocalPlayer/Help.pas

    r261 r290  
    208208destructor THyperText.Destroy;
    209209begin
    210   inherited Destroy;
     210  inherited;
    211211end;
    212212
     
    12371237      until FindNext(sr) <> 0;
    12381238    FindClose(sr);
    1239     Plus.Free;
     1239    FreeAndNil(Plus);
    12401240
    12411241    List.Sort;
     
    12541254      MainText.AddLine(s);
    12551255    end;
    1256     List.Free;
     1256    FreeAndNil(List);
    12571257  end;
    12581258
     
    12721272      MainText.AddLine(s);
    12731273    end;
    1274     List.Free;
     1274    FreeAndNil(List);
    12751275  end;
    12761276
     
    14341434            AppendList(List);
    14351435          end;
    1436           List.Free;
     1436          FreeAndNil(List);
    14371437        end
    14381438        else // single advance
     
    15331533          List.Sort;
    15341534          AppendList(List);
    1535           List.Free;
     1535          FreeAndNil(List);
    15361536        end
    15371537        else if no = 201 then
     
    18221822            AppendList(List);
    18231823          end;
    1824           List.Free;
     1824          FreeAndNil(List);
    18251825        end
    18261826        else
     
    19831983    OffscreenPaint;
    19841984    Invalidate;
    1985     HistItem.Free;
     1985    FreeAndNil(HistItem);
    19861986  end;
    19871987end;
  • trunk/LocalPlayer/IsoEngine.pas

    r245 r290  
    133133  OnInitEnemyModel := InitEnemyModelHandler;
    134134  if NoMap <> nil then
    135     NoMap.Free;
     135    FreeAndNil(NoMap);
    136136  NoMap := TIsoMap.Create;
    137137end;
     
    168168  { prepare dithered ground tiles }
    169169  if LandPatch <> nil then
    170     LandPatch.Free;
     170    FreeAndNil(LandPatch);
    171171  LandPatch := TBitmap.Create;
    172172  LandPatch.PixelFormat := pf24bit;
     
    175175  LandPatch.Canvas.FillRect(0, 0, LandPatch.Width, LandPatch.Height);
    176176  if OceanPatch <> nil then
    177     OceanPatch.Free;
     177    FreeAndNil(OceanPatch);
    178178  OceanPatch := TBitmap.Create;
    179179  OceanPatch.PixelFormat := pf24bit;
     
    363363      DitherMask.Canvas, 0, 0, SRCAND);
    364364
    365   LandMore.Free;
    366   OceanMore.Free;
    367   DitherMask.Free;
     365  FreeAndNil(LandMore);
     366  FreeAndNil(OceanMore);
     367  FreeAndNil(DitherMask);
    368368
    369369  // reduce size of terrain icons
     
    418418  end;
    419419  Mask24.EndUpdate;
    420   Mask24.Free;
     420  FreeAndNil(Mask24);
    421421
    422422  if Borders <> nil then
    423     Borders.Free;
     423    FreeAndNil(Borders);
    424424  Borders := TBitmap.Create;
    425425  Borders.PixelFormat := pf24bit;
  • trunk/LocalPlayer/MessgEx.lfm

    r232 r290  
    11object MessgExDlg: TMessgExDlg
    22  Left = 463
     3  Height = 134
    34  Top = 164
     5  Width = 418
    46  BorderIcons = []
    57  BorderStyle = bsNone
     
    810  ClientWidth = 418
    911  Color = clBtnFace
    10   Font.Charset = DEFAULT_CHARSET
     12  DesignTimePPI = 144
    1113  Font.Color = clWindowText
    1214  Font.Height = -13
    1315  Font.Name = 'MS Sans Serif'
    14   Font.Style = []
    1516  FormStyle = fsStayOnTop
    1617  OnClose = FormClose
     
    1920  OnPaint = FormPaint
    2021  OnShow = FormShow
    21   PixelsPerInch = 96
     22  LCLVersion = '2.0.12.0'
    2223  Scaled = False
    2324  object Button1: TButtonA
    2425    Left = 43
     26    Height = 25
    2527    Top = 104
    2628    Width = 100
    27     Height = 25
    2829    Down = False
    2930    Permanent = False
    3031    OnClick = Button1Click
    31     Caption = ''
    3232  end
    3333  object Button2: TButtonA
    3434    Left = 159
     35    Height = 25
    3536    Top = 104
    3637    Width = 100
    37     Height = 25
    3838    Down = False
    3939    Permanent = False
    4040    OnClick = Button2Click
    41     Caption = ''
    4241  end
    4342  object Button3: TButtonA
    4443    Left = 275
     44    Height = 25
    4545    Top = 104
    4646    Width = 100
    47     Height = 25
    4847    Down = False
    4948    Permanent = False
    5049    OnClick = Button3Click
    51     Caption = ''
    5250  end
    5351  object RemoveBtn: TButtonB
    5452    Left = 384
     53    Height = 25
    5554    Top = 104
    5655    Width = 25
    57     Height = 25
    5856    Down = False
    5957    Permanent = False
     
    6361  object EInput: TEdit
    6462    Left = 125
     63    Height = 26
    6564    Top = 64
    6665    Width = 168
    67     Height = 19
    68     TabStop = False
    6966    BorderStyle = bsNone
    7067    Color = clBlack
    71     Font.Charset = DEFAULT_CHARSET
    7268    Font.Color = 4176863
    7369    Font.Height = -15
     
    7571    Font.Style = [fsBold]
    7672    ParentFont = False
     73    TabStop = False
    7774    TabOrder = 0
    7875  end
  • trunk/LocalPlayer/MessgEx.pas

    r245 r290  
    218218  end
    219219  else
    220     result := inherited ShowModal;
     220    result := inherited;
    221221end;
    222222
  • trunk/LocalPlayer/NatStat.pas

    r189 r290  
    9898procedure TNatStatDlg.FormDestroy(Sender: TObject);
    9999begin
    100   ReportText.Free;
     100  FreeAndNil(ReportText);
    101101  FreeMem(SelfReport);
    102   Template.Free;
    103   Back.Free;
     102  FreeAndNil(Template);
     103  FreeAndNil(Back);
    104104end;
    105105
  • trunk/LocalPlayer/Term.pas

    r288 r290  
    12431243    if AILogo[p] <> nil then
    12441244    begin
    1245       AILogo[p].free;
    1246       AILogo[p] := nil
     1245      FreeAndNil(AILogo[p]);
    12471246    end
    12481247  end
     
    12531252    if not LoadGraphicFile(AILogo[p], HomeDir + Name + '.png', gfNoError) then
    12541253    begin
    1255       AILogo[p].free;
    1256       AILogo[p] := nil
     1254      FreeAndNil(AILogo[p]);
    12571255    end
    12581256  end
     
    24972495    cReleaseModule:
    24982496      begin
    2499         SmallImp.free;
    2500         UnusedTribeFiles.free;
    2501         TribeNames.free;
    2502         MainMap.free;
     2497        FreeAndNil(SmallImp);
     2498        FreeAndNil(UnusedTribeFiles);
     2499        FreeAndNil(TribeNames);
     2500        FreeAndNil(MainMap);
    25032501        IsoEngine.Done;
    25042502        // AdvisorDlg.DeInit;
     
    26982696        for p1 := 0 to nPl - 1 do
    26992697          if Tribe[p1] <> nil then
    2700             Tribe[p1].free;
     2698            FreeAndNil(Tribe[p1]);
    27012699        Tribes.Done;
    27022700        RepaintOnResize := false;
  • trunk/LocalPlayer/Tribes.pas

    r98 r290  
    9090    begin
    9191      ReallocMem(PictureList, 0);
    92       StdUnitScript.Free;
     92      FreeAndNil(StdUnitScript);
    9393    end;
    9494
     
    313313  destructor TTribe.Destroy;
    314314  begin
    315     Script.Free;
    316     inherited Destroy;
     315    FreeAndNil(Script);
     316    inherited;
    317317  end;
    318318
  • trunk/LocalPlayer/UnitStat.pas

    r209 r290  
    8888procedure TUnitStatDlg.FormDestroy(Sender: TObject);
    8989begin
    90   Template.Free;
    91   Back.Free;
     90  FreeAndNil(Template);
     91  FreeAndNil(Back);
    9292end;
    9393
  • trunk/NoTerm.pas

    r188 r290  
    2525    G: TNewGameData;
    2626    Server: TServerCall;
    27     Shade, State: TBitmap;
     27    Shade: TBitmap;
     28    State: TBitmap;
    2829    WinStat, ExtStat, AloneStat: array [0 .. nPl - 1] of integer;
    2930    DisallowShowActive: array [0 .. nPl - 1] of boolean;
     
    163164    cReleaseModule:
    164165      begin
    165         Shade.Free;
    166         State.Free;
     166        FreeAndNil(Shade);
     167        FreeAndNil(State);
    167168      end;
    168169
     
    245246                    ShipComplete := false;
    246247                if ShipComplete then
    247                   inc(WinStat[p])
     248                  inc(WinStat[p]);
    248249              end;
    249250          if Mode = Running then
     
    255256        begin
    256257          GoBtn.ButtonIndex := 22;
    257           Mode := Stopped
    258         end
     258          Mode := Stopped;
     259        end;
    259260      end;
    260261
     
    277278        if (Active >= 0) and not DisallowShowActive[Active] then
    278279          ShowActive(Active, true);
    279       end
    280 
    281   end
     280      end;
     281  end;
    282282end;
    283283
     
    292292    GoBtn.Update;
    293293    Server(sTurn, me, 0, nil^);
    294   end
     294  end;
    295295end;
    296296
     
    300300    EndPlaying
    301301  else
    302     Mode := Quit
     302    Mode := Quit;
    303303end;
    304304
  • trunk/Packages/CevoComponents/AsyncProcess2.pas

    r287 r290  
    104104procedure TAsyncProcess.Execute;
    105105begin
    106   inherited Execute;
     106  inherited;
    107107
    108108  if poUsePipes in Options then
  • trunk/Packages/CevoComponents/BaseWin.pas

    r188 r290  
    106106destructor TBufferedDrawDlg.Destroy;
    107107begin
    108   Offscreen.Free;
    109   inherited Destroy;
     108  FreeAndNil(Offscreen);
     109  inherited;
    110110end;
    111111
  • trunk/Packages/CevoComponents/ButtonA.pas

    r209 r290  
    3535constructor TButtonA.Create(aOwner: TComponent);
    3636begin
    37   inherited Create(aOwner);
     37  inherited;
    3838  FCaption := '';
    3939  SetBounds(0, 0, 100, 25);
  • trunk/Packages/CevoComponents/ButtonB.pas

    r188 r290  
    3838constructor TButtonB.Create(aOwner: TComponent);
    3939begin
    40   inherited Create(aOwner);
     40  inherited;
    4141  ShowHint := True;
    4242  SetBounds(0, 0, 25, 25);
  • trunk/Packages/CevoComponents/ButtonC.pas

    r188 r290  
    3232constructor TButtonC.Create(aOwner: TComponent);
    3333begin
    34   inherited Create(aOwner);
     34  inherited;
    3535  ShowHint := True;
    3636  SetBounds(0, 0, 12, 12);
  • trunk/Packages/CevoComponents/ButtonN.pas

    r188 r290  
    4545constructor TButtonN.Create(aOwner: TComponent);
    4646begin
    47   inherited Create(aOwner);
     47  inherited;
    4848  ShowHint := true;
    4949  FGraphic := nil;
  • trunk/Packages/CevoComponents/DrawDlg.pas

    r257 r290  
    7777begin
    7878  RemoveHandlerOnVisibleChanged(VisibleChangedHandler);
    79   inherited Destroy;
     79  inherited;
    8080end;
    8181
     
    175175begin
    176176  if Key = VK_ESCAPE then Close;
    177   inherited KeyDown(Key, Shift);
     177  inherited;
    178178end;
    179179
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r288 r290  
    258258    MenuItem := MenuItems[MenuItems.Count - 1];
    259259    MenuItems.Delete(MenuItems.Count - 1);
    260     MenuItem.Free;
     260    FreeAndNil(MenuItem);
    261261  end;
    262262end;
     
    439439      Bmp.Canvas.Draw(0, 0, jtex);
    440440    end;
    441     jtex.Free;
     441    FreeAndNil(jtex);
    442442  end
    443443  else
     
    464464        Bmp.Canvas.draw(0, 0, Png);
    465465    end;
    466     Png.Free;
     466    FreeAndNil(Png);
    467467  end
    468468  else
     
    17261726  RestoreResolution;
    17271727  for I := 0 to nGrExt - 1 do begin
    1728     GrExt[I].Data.Free;
    1729     GrExt[I].Mask.Free;
     1728    FreeAndNil(GrExt[I].Data);
     1729    FreeAndNil(GrExt[I].Mask);
    17301730    FreeMem(GrExt[I]);
    17311731  end;
  • trunk/Packages/CevoComponents/Sound.lfm

    r111 r290  
    88  Caption = 'SoundPlayer'
    99  Color = clBtnFace
    10   DesignTimePPI = 125
     10  DesignTimePPI = 144
    1111  Font.Color = clWindowText
    1212  Font.Height = -11
    1313  Font.Name = 'MS Sans Serif'
    14   LCLVersion = '1.8.0.6'
     14  LCLVersion = '2.0.12.0'
    1515  Scaled = False
    1616end
  • trunk/Packages/CevoComponents/Sound.pas

    r288 r290  
    220220      end;
    221221    finally
    222       L.Free;
     222      FreeAndNil(L);
    223223    end;
    224224  end
  • trunk/Platform.pas

    r207 r290  
    5858finalization
    5959
    60 NowPreciseLock.Free;
     60FreeAndNil(NowPreciseLock);
    6161
    6262end.
  • trunk/Start.lfm

    r232 r290  
    2525  OnPaint = FormPaint
    2626  OnShow = FormShow
    27   LCLVersion = '2.0.2.0'
    28   PixelsPerInch = 96
     27  LCLVersion = '2.0.12.0'
    2928  Scaled = False
    3029  object StartBtn: TButtonA
     
    205204  end
    206205  object PopupMenu1: TPopupMenu
    207     left = 8
    208     top = 8
     206    Left = 8
     207    Top = 8
    209208  end
    210209end
  • trunk/Start.pas

    r283 r290  
    244244begin
    245245  FreeAndNil(Bitmap);
    246   inherited Destroy;
     246  inherited;
    247247end;
    248248
     
    471471      Brains.GetByKind(btAI, AIBrains);
    472472      BrainDefault := Brains[0];
    473       AIBrains.Free;
     473      FreeAndNil(AIBrains);
    474474    end; // default AI not found, use any
    475475
     
    698698    end;
    699699  end;
    700   AIBrains.Free;
     700  FreeAndNil(AIBrains);
    701701end;
    702702
     
    14111411      if AIBrains[I].Flags and fMultiple <> 0 then
    14121412        OfferBrain(AIBrains[I], FixedLines);
    1413     AIBrains.Free;
     1413    FreeAndNil(AIBrains);
    14141414  end else begin
    14151415    FixedLines := 0;
     
    14391439          or (Brains[I] = PlayersBrain[PlayerPopupIndex]) then
    14401440          OfferBrain(AIBrains[i], FixedLines);
    1441       AIBrains.Free;
     1441      FreeAndNil(AIBrains);
    14421442    end;
    14431443  end;
  • trunk/UKeyBindings.pas

    r288 r290  
    9797    end;
    9898  finally
    99     Lines.Free;
     99    FreeAndNil(Lines);
    100100  end;
    101101end;
     
    114114    Lines.SaveToFile(FileName);
    115115  finally
    116     Lines.Free;
     116    FreeAndNil(Lines);
    117117  end;
    118118end;
  • trunk/UnitProcessing.pas

    r38 r290  
    55
    66uses
    7   Protocol, Database;
     7  SysUtils, Protocol, Database;
    88
    99type
     
    10351035    end
    10361036  end;
    1037   Q.Free;
     1037  FreeAndNil(Q);
    10381038  if (Loc = a.ToLoc) or (a.ToLoc = maNextCity) and (Loc >= 0) and
    10391039    (Map[Loc] and fCity <> 0) then
     
    11651165    end
    11661166  end;
    1167   Q.Free;
     1167  FreeAndNil(Q);
    11681168end; // CanPlaneReturn
    11691169
Note: See TracChangeset for help on using the changeset viewer.