Skip to content

Commit

Permalink
fix mem leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
alanphys committed Apr 16, 2020
1 parent 864362b commit 85ce876
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 115 deletions.
8 changes: 0 additions & 8 deletions beamunit.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,6 @@ object BeamForm: TBeamForm
ShowHint = True
TabOrder = 6
end
object SaveDialog: TSaveDialog
Title = 'Save Beam Data Ffile as'
DefaultExt = '.bdf'
Filter = 'Beam Data Files | *.bdf'
FilterIndex = 0
left = 552
top = 136
end
object OpenDialog: TOpenDialog
Title = 'Open Beam Data File'
DefaultExt = '.bdf'
Expand Down
12 changes: 5 additions & 7 deletions beamunit.lrs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ LazarusResources.Add('TBeamForm','FORMDATA',[
+'bOrder'#2#1#0#0#7'TBitBtn'#8'bbFinish'#4'Left'#3#180#1#6'Height'#2#25#4'Hin'
+'t'#6#14'Save and Close'#3'Top'#3#0#1#5'Width'#2'K'#25'BorderSpacing.InnerBo'
+'rder'#2#2#7'Caption'#6#6'Finish'#7'OnClick'#7#13'bbExportClick'#14'ParentSh'
+'owHint'#8#8'ShowHint'#9#8'TabOrder'#2#6#0#0#11'TSaveDialog'#10'SaveDialog'#5
+'Title'#6#23'Save Beam Data Ffile as'#10'DefaultExt'#6#4'.bdf'#6'Filter'#6#23
+'Beam Data Files | *.bdf'#11'FilterIndex'#2#0#4'left'#3'('#2#3'top'#3#136#0#0
+#0#11'TOpenDialog'#10'OpenDialog'#5'Title'#6#19'Open Beam Data File'#10'Defa'
+'ultExt'#6#4'.bdf'#6'Filter'#6'6Beam Data Files | *.bdf|Text Files|*.txt|All'
+' files|*.*'#11'FilterIndex'#2#0#4'left'#3'('#2#3'top'#3#176#0#0#0#12'TPrint'
+'Dialog'#11'PrintDialog'#4'left'#3'('#2#3'top'#3#216#0#0#0#0
+'owHint'#8#8'ShowHint'#9#8'TabOrder'#2#6#0#0#11'TOpenDialog'#10'OpenDialog'#5
+'Title'#6#19'Open Beam Data File'#10'DefaultExt'#6#4'.bdf'#6'Filter'#6'6Beam'
+' Data Files | *.bdf|Text Files|*.txt|All files|*.*'#11'FilterIndex'#2#0#4'l'
+'eft'#3'('#2#3'top'#3#176#0#0#0#12'TPrintDialog'#11'PrintDialog'#4'left'#3'('
+#2#3'top'#3#216#0#0#0#0
]);
71 changes: 36 additions & 35 deletions beamunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
1/2/2011 fixed dynamic array reference problem for CRC
1/2/2011 fixed date format problem
24/5/2019 fixed empty cell and data bugs
28/2/2020 remove definitions and use from opfunit}
28/2/2020 remove definitions and use from opfunit
24/3/2020 store all beam config files automatically in program config dir}

{$mode DELPHI}{$H+}

Expand Down Expand Up @@ -53,7 +54,6 @@ TBeamForm = class(TForm)
OpenDialog: TOpenDialog;
PageControl: TPageControl;
PrintDialog: TPrintDialog;
SaveDialog: TSaveDialog;
sgTable: TStringGrid;
sgTray: TStringGrid;
sgOPF: TStringGrid;
Expand Down Expand Up @@ -86,7 +86,7 @@ TBeamForm = class(TForm)

implementation

uses CRC32;
uses CRC32, LazFileUtils;

{ TBeamForm }

Expand Down Expand Up @@ -156,7 +156,7 @@ procedure TBeamForm.bbExportClick(Sender: TObject);
I,J,K: integer; {loop variables}
CRCValue :dword; {holder for checksum}
Size :integer; {size of field}
sExePath :string; {program directory}
sDataPath :string; {program data dir}
CellVal :double; {value of the cell}

begin
Expand Down Expand Up @@ -228,43 +228,44 @@ procedure TBeamForm.bbExportClick(Sender: TObject);
end;
Linac.LinacRec.Checksum := CRCValue;

{Set directory path to program files}
sExePath := ExtractFilePath(Application.ExeName);
SetCurrentDir(sExePath);
{get path to program config data}
{$ifdef WINDOWS}
sDataPath := GetAppConfigDir(true);
{$else}
sDataPath := GetAppConfigDir(false);
{$endif}

{write data to text file}
SaveDialog.FileName := Linac.LinacRec.Name + '.bdf';
if SaveDialog.Execute then
sDataPath := AppendPathDelim(sDataPath) + Linac.LinacRec.Name + '.bdf';
AssignFile(OutFile,sDataPath);
Rewrite(Outfile);
Writeln(Outfile,Checksum);
Writeln(Outfile,Title);
Writeln(Outfile,Name);
Writeln(Outfile,Noe);
Writeln(Outfile,EDate);
for I:=1 to NoE do
begin
AssignFile(OutFile,SaveDialog.Filename);
Rewrite(Outfile);
Writeln(Outfile,Checksum);
Writeln(Outfile,Title);
Writeln(Outfile,Name);
Writeln(Outfile,Noe);
Writeln(Outfile,EDate);
for I:=1 to NoE do
Writeln(Outfile,Energy[I]);
Writeln(Outfile,DM[I]:4:3);
Writeln(Outfile,Table[I]:4:3);
for J:=1 to 5 do Write(Outfile,Tray[I,J]:4:3,' ');
writeln(Outfile);
for J:=1 to 6 do Write(Outfile,S[I,J]:9:8,' ');
writeln(Outfile,S[I,7]:9:8);
writeln(Outfile,Length(TMR[I]));
if length(TMR[I]) > 0 then writeln(Outfile,Length(TMR[I,0]))
else writeln(Outfile,0);
for J:=0 to Length(TMR[I]) - 1 do
begin
Writeln(Outfile,Energy[I]);
Writeln(Outfile,DM[I]:4:3);
Writeln(Outfile,Table[I]:4:3);
for J:=1 to 5 do Write(Outfile,Tray[I,J]:4:3,' ');
writeln(Outfile);
for J:=1 to 6 do Write(Outfile,S[I,J]:9:8,' ');
writeln(Outfile,S[I,7]:9:8);
writeln(Outfile,Length(TMR[I]));
if length(TMR[I]) > 0 then writeln(Outfile,Length(TMR[I,0]))
else writeln(Outfile,0);
for J:=0 to Length(TMR[I]) - 1 do
begin
for K:=0 to Length(TMR[I,J]) - 1 do
Write(Outfile,TMR[I,J,K]:5:3,' ');
Writeln(Outfile);
end;
for K:=0 to Length(TMR[I,J]) - 1 do
Write(Outfile,TMR[I,J,K]:5:3,' ');
Writeln(Outfile);
end;
Closefile(Outfile);
Close;
end;
Closefile(Outfile);
Linac.Free;
Close;
end;
end;

Expand Down
1 change: 1 addition & 0 deletions loginunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function SHA256(sText:string):string;
Result:= '';
for I:= 0 to 31 do
Result:= Result + IntToHex(Digest[I],2);
Hash.Free;
end;

{ TLoginForm }
Expand Down
Binary file modified opf
Binary file not shown.
Binary file modified opf.exe
Binary file not shown.
107 changes: 54 additions & 53 deletions opf.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,21 @@
<Unit0>
<Filename Value="opf.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos Y="17"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<CursorPos X="27" Y="25"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="opfunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="OPFForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="19"/>
<CursorPos X="54" Y="48"/>
<TopLine Value="47"/>
<CursorPos X="24" Y="65"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
Expand Down Expand Up @@ -129,7 +130,7 @@
<ComponentName Value="Resform"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<EditorIndex Value="4"/>
<EditorIndex Value="5"/>
<TopLine Value="143"/>
<CursorPos X="51" Y="176"/>
<UsageCount Value="200"/>
Expand Down Expand Up @@ -366,9 +367,9 @@
<ComponentName Value="AboutForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<EditorIndex Value="3"/>
<EditorIndex Value="4"/>
<CursorPos X="44" Y="38"/>
<UsageCount Value="117"/>
<UsageCount Value="123"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit47>
Expand Down Expand Up @@ -549,10 +550,10 @@
<ComponentName Value="LoginForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<EditorIndex Value="2"/>
<TopLine Value="185"/>
<CursorPos X="20" Y="181"/>
<UsageCount Value="26"/>
<EditorIndex Value="3"/>
<TopLine Value="38"/>
<CursorPos X="11" Y="60"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit73>
Expand Down Expand Up @@ -591,133 +592,132 @@
<ComponentName Value="BeamForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="82"/>
<CursorPos X="92" Y="100"/>
<UsageCount Value="25"/>
<CursorPos X="11" Y="247"/>
<UsageCount Value="31"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit78>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="opfunit.pas"/>
<Caret Line="525" Column="13" TopLine="493"/>
<Caret Line="600" Column="32" TopLine="568"/>
</Position1>
<Position2>
<Filename Value="opfunit.pas"/>
<Caret Line="527" Column="13" TopLine="495"/>
<Caret Line="606" Column="19" TopLine="568"/>
</Position2>
<Position3>
<Filename Value="opfunit.pas"/>
<Caret Line="528" Column="32" TopLine="496"/>
<Caret Line="606" Column="29" TopLine="586"/>
</Position3>
<Position4>
<Filename Value="opfunit.pas"/>
<Caret Line="529" Column="13" TopLine="503"/>
<Caret Line="111" Column="19" TopLine="88"/>
</Position4>
<Position5>
<Filename Value="opfunit.pas"/>
<Caret Line="148" Column="51" TopLine="119"/>
<Caret Line="422" Column="4" TopLine="420"/>
</Position5>
<Position6>
<Filename Value="opfunit.pas"/>
<Caret Line="825" Column="22" TopLine="816"/>
<Caret Line="441" TopLine="421"/>
</Position6>
<Position7>
<Filename Value="opfunit.pas"/>
<Caret Line="870" Column="11" TopLine="837"/>
<Caret Line="436" TopLine="421"/>
</Position7>
<Position8>
<Filename Value="opfunit.pas"/>
<Caret Line="849" Column="37" TopLine="829"/>
<Caret Line="427" Column="28" TopLine="408"/>
</Position8>
<Position9>
<Filename Value="opfunit.pas"/>
<Caret Line="10" Column="20"/>
<Caret Line="434" Column="33" TopLine="414"/>
</Position9>
<Position10>
<Filename Value="opfunit.pas"/>
<Caret Line="18" Column="31"/>
<Caret Line="55" Column="4" TopLine="28"/>
</Position10>
<Position11>
<Filename Value="opfunit.pas"/>
<Caret Line="254" Column="69" TopLine="222"/>
<Caret Line="44" Column="31" TopLine="29"/>
</Position11>
<Position12>
<Filename Value="opfunit.pas"/>
<Caret Line="255" Column="63" TopLine="223"/>
<Caret Line="304" Column="16" TopLine="290"/>
</Position12>
<Position13>
<Filename Value="opfunit.pas"/>
<Caret Line="355" Column="9" TopLine="323"/>
<Filename Value="beamunit.pas"/>
<Caret Line="11" Column="50"/>
</Position13>
<Position14>
<Filename Value="opfunit.pas"/>
<Caret Line="369" Column="6" TopLine="337"/>
<Caret Line="995" TopLine="976"/>
</Position14>
<Position15>
<Filename Value="opfunit.pas"/>
<Caret Line="504" Column="12" TopLine="472"/>
<Caret Line="445" Column="47" TopLine="430"/>
</Position15>
<Position16>
<Filename Value="opfunit.pas"/>
<Caret Line="600" Column="32" TopLine="568"/>
<Caret Line="684" Column="61" TopLine="658"/>
</Position16>
<Position17>
<Filename Value="opfunit.pas"/>
<Caret Line="606" Column="19" TopLine="568"/>
<Caret Line="676" Column="20" TopLine="656"/>
</Position17>
<Position18>
<Filename Value="opfunit.pas"/>
<Caret Line="606" Column="29" TopLine="586"/>
<Filename Value="beamunit.pas"/>
<Caret Line="268" TopLine="233"/>
</Position18>
<Position19>
<Filename Value="opfunit.pas"/>
<Caret Line="111" Column="19" TopLine="88"/>
<Filename Value="beamunit.pas"/>
<Caret Line="267" TopLine="232"/>
</Position19>
<Position20>
<Filename Value="opfunit.pas"/>
<Caret Line="422" Column="4" TopLine="420"/>
<Caret Line="550" Column="37" TopLine="525"/>
</Position20>
<Position21>
<Filename Value="opfunit.pas"/>
<Caret Line="441" TopLine="421"/>
<Filename Value="opf.lpr"/>
<Caret Line="7" Column="70"/>
</Position21>
<Position22>
<Filename Value="opfunit.pas"/>
<Caret Line="436" TopLine="421"/>
<Caret Line="1033" Column="57" TopLine="966"/>
</Position22>
<Position23>
<Filename Value="opfunit.pas"/>
<Caret Line="427" Column="28" TopLine="408"/>
<Caret Line="715" Column="21" TopLine="708"/>
</Position23>
<Position24>
<Filename Value="opfunit.pas"/>
<Caret Line="434" Column="33" TopLine="414"/>
<Caret Line="541" TopLine="522"/>
</Position24>
<Position25>
<Filename Value="opfunit.pas"/>
<Caret Line="55" Column="4" TopLine="28"/>
<Filename Value="loginunit.pas"/>
<Caret Line="181" Column="20" TopLine="185"/>
</Position25>
<Position26>
<Filename Value="opfunit.pas"/>
<Caret Line="44" Column="31" TopLine="29"/>
<Caret Line="65" Column="24" TopLine="47"/>
</Position26>
<Position27>
<Filename Value="opfunit.pas"/>
<Caret Line="304" Column="16" TopLine="290"/>
<Filename Value="opf.lpr"/>
<Caret Line="7" Column="20"/>
</Position27>
<Position28>
<Filename Value="beamunit.pas"/>
<Caret Line="11" Column="50"/>
<Caret Line="29" Column="5"/>
</Position28>
<Position29>
<Filename Value="opfunit.pas"/>
<Caret Line="995" TopLine="976"/>
<Filename Value="beamunit.pas"/>
<Caret Line="164" Column="45" TopLine="143"/>
</Position29>
<Position30>
<Filename Value="opfunit.pas"/>
<Caret Line="445" Column="47" TopLine="430"/>
<Filename Value="opf.lpr"/>
<Caret Line="2" Column="3"/>
</Position30>
</JumpHistory>
</ProjectOptions>
Expand Down Expand Up @@ -745,6 +745,7 @@
<Debugging>
<GenerateDebugInfo Value="False"/>
<DebugInfoType Value="dsDwarf2Set"/>
<UseLineInfoUnit Value="False"/>
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
Expand Down
Loading

0 comments on commit 85ce876

Please sign in to comment.