Memory leaks fixed

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5697 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-25 09:33:15 +00:00
parent 7b7bf9aa54
commit ca3030d268
7 changed files with 440 additions and 360 deletions

View File

@ -23,10 +23,10 @@
<VersionInfo> <VersionInfo>
<UseVersionInfo Value="True"/> <UseVersionInfo Value="True"/>
<MinorVersionNr Value="1"/> <MinorVersionNr Value="1"/>
<RevisionNr Value="13"/> <RevisionNr Value="14"/>
<StringTable CompanyName="minesadorada" FileDescription="Tray app that works with LazAutoUpdate apps" InternalName="lazautoupdater" LegalCopyright="LGPLv2" LegalTrademarks="(c)2014 Gordon Bamber" OriginalFilename="trayupdater" ProductName="Lazarus 1.x FPC 2.6.x" ProductVersion="0.1.11.2"/> <StringTable CompanyName="minesadorada" FileDescription="Tray app that works with LazAutoUpdate apps" InternalName="lazautoupdater" LegalCopyright="LGPLv2" LegalTrademarks="(c)2014 Gordon Bamber" OriginalFilename="trayupdater" ProductName="Lazarus 1.x FPC 2.6.x" ProductVersion="0.1.11.2"/>
</VersionInfo> </VersionInfo>
<BuildModes Count="4"> <BuildModes Count="5">
<Item1 Name="Win32 Release" Default="True"/> <Item1 Name="Win32 Release" Default="True"/>
<Item2 Name="Win64 Release"> <Item2 Name="Win64 Release">
<CompilerOptions> <CompilerOptions>
@ -101,6 +101,9 @@
</Linking> </Linking>
<Other> <Other>
<CustomOptions Value="-FcUTF8"/> <CustomOptions Value="-FcUTF8"/>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
</Other> </Other>
</CompilerOptions> </CompilerOptions>
</Item3> </Item3>
@ -143,6 +146,58 @@
</Other> </Other>
</CompilerOptions> </CompilerOptions>
</Item4> </Item4>
<Item5 Name="Win64 Debug">
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="compiled\win64debug\lautraynotifywin64"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\packagesource"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
<VerifyObjMethodCallValidity Value="True"/>
<TargetCPU Value="x86_64"/>
<TargetOS Value="win64"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<UseHeaptrc Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-FcUTF8
-dDEBUGMODE"/>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
</Other>
</CompilerOptions>
</Item5>
</BuildModes> </BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>

View File

@ -3,16 +3,17 @@
<ProjectSession> <ProjectSession>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="10"/> <Version Value="10"/>
<BuildModes Active="Win64 Release"/> <BuildModes Active="Win64 Debug"/>
<Units Count="30"> <Units Count="30">
<Unit0> <Unit0>
<Filename Value="trayupdater.lpr"/> <Filename Value="trayupdater.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<WindowIndex Value="1"/> <WindowIndex Value="1"/>
<TopLine Value="21"/> <TopLine Value="3"/>
<CursorPos X="58" Y="41"/> <CursorPos X="19" Y="10"/>
<UsageCount Value="181"/> <UsageCount Value="182"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -21,14 +22,18 @@
<ComponentName Value="mainform"/> <ComponentName Value="mainform"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<WindowIndex Value="1"/> <WindowIndex Value="1"/>
<TopLine Value="540"/> <CursorPos Y="23"/>
<CursorPos X="50" Y="552"/> <ExtraEditorCount Value="1"/>
<ExtraEditor1>
<IsVisibleTab Value="True"/>
<TopLine Value="92"/>
<CursorPos X="52" Y="119"/>
</ExtraEditor1>
<ComponentState Value="1"/> <ComponentState Value="1"/>
<UsageCount Value="181"/> <UsageCount Value="182"/>
<Bookmarks Count="1"> <Bookmarks Count="1">
<Item0 X="3" Y="480" ID="2"/> <Item0 X="3" Y="481" ID="2"/>
</Bookmarks> </Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@ -41,9 +46,8 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<WindowIndex Value="1"/> <WindowIndex Value="1"/>
<TopLine Value="150"/> <CursorPos X="2" Y="22"/>
<CursorPos X="37" Y="224"/> <UsageCount Value="178"/>
<UsageCount Value="177"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit2> </Unit2>
@ -251,126 +255,129 @@
<OtherDefines Count="1"> <OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/> <Define0 Value="DEBUGMODE"/>
</OtherDefines> </OtherDefines>
<General>
<ActiveWindowIndexAtStart Value="1"/>
</General>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="trayupdater.lpr"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="63" TopLine="14"/> <Caret Column="17"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="trayupdater.lpr"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="57" Column="30" TopLine="19"/> <Caret Line="852" Column="20" TopLine="814"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="umainform.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="593" Column="31" TopLine="587"/> <Caret Line="932" Column="16" TopLine="894"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1482" Column="40" TopLine="1460"/> <Caret Line="1120" Column="18" TopLine="1083"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="umainform.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="137" TopLine="109"/> <Caret Line="1327" Column="18" TopLine="1290"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2296" Column="87" TopLine="2285"/> <Caret Line="1460" Column="16" TopLine="1422"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Column="17"/> <Caret Line="1528" Column="16" TopLine="1490"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="852" Column="20" TopLine="814"/> <Caret Line="1572" Column="20" TopLine="1535"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="932" Column="16" TopLine="894"/> <Caret Line="1611" Column="20" TopLine="1573"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1120" Column="18" TopLine="1083"/> <Caret Line="1696" Column="16" TopLine="1659"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1327" Column="18" TopLine="1290"/> <Caret Line="1729" Column="20" TopLine="1692"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1460" Column="16" TopLine="1422"/> <Caret Line="1820" Column="22" TopLine="1783"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1528" Column="16" TopLine="1490"/> <Caret Line="1857" Column="25" TopLine="1820"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1572" Column="20" TopLine="1535"/> <Caret Line="1892" Column="27" TopLine="1855"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1611" Column="20" TopLine="1573"/> <Caret Line="1976" Column="22" TopLine="1939"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1696" Column="16" TopLine="1659"/> <Caret Line="2030" Column="25" TopLine="1993"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1729" Column="20" TopLine="1692"/> <Caret Line="2071" Column="27" TopLine="2034"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="1820" Column="22" TopLine="1783"/> <Caret Line="407" Column="36" TopLine="386"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="1857" Column="25" TopLine="1820"/> <Caret Line="496" Column="46" TopLine="468"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="1892" Column="27" TopLine="1855"/> <Caret Line="497" Column="37" TopLine="468"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="1976" Column="22" TopLine="1939"/> <Caret Line="502" Column="46" TopLine="468"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="2030" Column="25" TopLine="1993"/> <Caret Line="73" Column="12" TopLine="50"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="2071" Column="27" TopLine="2034"/> <Caret Line="563" Column="9" TopLine="540"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="407" Column="36" TopLine="386"/> <Caret Line="572" Column="15" TopLine="540"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="496" Column="46" TopLine="468"/> <Caret Line="735" Column="27" TopLine="715"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="497" Column="37" TopLine="468"/> <Caret Line="77" Column="73" TopLine="50"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="502" Column="46" TopLine="468"/> <Caret Line="664" Column="3" TopLine="677"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="73" Column="12" TopLine="50"/> <Caret Line="746" Column="26" TopLine="715"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="umainform.pas"/> <Filename Value="trayupdater.lpr"/>
<Caret Line="563" Column="9" TopLine="540"/> <Caret Line="36" Column="30" TopLine="21"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="572" Column="15" TopLine="540"/> <Caret Line="743" Column="48" TopLine="719"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>

View File

@ -172,7 +172,6 @@ object configform: Tconfigform
ClientHeight = 223 ClientHeight = 223
ClientWidth = 600 ClientWidth = 600
TabOrder = 1 TabOrder = 1
OnClick = grp_updateintervalClick
object cmd_Close: TBitBtn object cmd_Close: TBitBtn
Left = 228 Left = 228
Height = 30 Height = 30

View File

@ -1,18 +1,38 @@
unit uconfigform; unit uconfigform;
{ LazAutoUpdater Tray Updater
Copyright (C)2014 Gordon Bamber minesadorada@charcodelvalle.com
An example of using LazAutoUpdate as a silent updater
This source is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This code is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
A copy of the GNU General Public License is available on the World Wide Web
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
}
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Dialogs, Buttons, SysUtils, Forms, Controls, Dialogs, Buttons,
StdCtrls, EditBtn; StdCtrls, EditBtn;
type type
{ Tconfigform } { Tconfigform }
Tconfigform = class(TForm) Tconfigform = class(TForm)
cmd_DeleteAppProfile: TButton; cmd_DeleteAppProfile: TButton;
cmd_SaveChanges: TBitBtn; cmd_SaveChanges: TBitBtn;
chk_Update: TCheckBox; chk_Update: TCheckBox;
@ -53,25 +73,24 @@ Tconfigform = class(TForm)
procedure cmb_IntervalTypeChange(Sender: TObject); procedure cmb_IntervalTypeChange(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure grp_updateintervalClick(Sender: TObject); private
private
{ private declarations } { private declarations }
procedure DoInitialiseCombobox; procedure DoInitialiseCombobox;
procedure DoDisplayProfile(AIndex: integer); procedure DoDisplayProfile(AIndex: integer);
procedure DoSaveAllChanges; procedure DoSaveAllChanges;
procedure DoEnableDisableIntervalCombos; procedure DoEnableDisableIntervalCombos;
public public
{ public declarations } { public declarations }
bDetailsChanged: boolean; bDetailsChanged: boolean;
end; end;
var var
configform : Tconfigform; configform: Tconfigform;
implementation implementation
uses uses
umainform; umainform;
{$R *.lfm} {$R *.lfm}
@ -164,7 +183,7 @@ end;
procedure Tconfigform.chk_UpdateClick(Sender: TObject); procedure Tconfigform.chk_UpdateClick(Sender: TObject);
begin begin
mainform.AppRecArray[cmb_AppProfile.ItemIndex].Update := chk_Update.Checked; mainform.AppRecArray[cmb_AppProfile.ItemIndex].Update := chk_Update.Checked;
// mainform.LongTimerArray[cmb_AppProfile.ItemIndex].Enabled := chk_Update.Checked; // mainform.LongTimerArray[cmb_AppProfile.ItemIndex].Enabled := chk_Update.Checked;
end; end;
procedure Tconfigform.cmb_AppProfileClick(Sender: TObject); procedure Tconfigform.cmb_AppProfileClick(Sender: TObject);
@ -187,8 +206,8 @@ procedure Tconfigform.cmd_DeleteAppProfileClick(Sender: TObject);
// Copy the temp copy back to AppRecArray // Copy the temp copy back to AppRecArray
// Delete the INIFile section // Delete the INIFile section
var var
TempAppRecArray : array of TAppRec; TempAppRecArray: array of TAppRec;
i, iLastIndex : integer; i, iLastIndex: integer;
begin begin
if High(mainform.AppRecArray) = 0 then if High(mainform.AppRecArray) = 0 then
begin begin
@ -225,8 +244,8 @@ end;
procedure Tconfigform.cmd_NewAppProfileClick(Sender: TObject); procedure Tconfigform.cmd_NewAppProfileClick(Sender: TObject);
var var
szProfileName : string; szProfileName: string;
iLastIndex : integer; iLastIndex: integer;
begin begin
if InputQuery('New Profile', 'New Profile', False, szProfileName) then if InputQuery('New Profile', 'New Profile', False, szProfileName) then
begin begin
@ -253,7 +272,7 @@ end;
procedure Tconfigform.DoInitialiseCombobox; procedure Tconfigform.DoInitialiseCombobox;
var var
i : integer; i: integer;
begin begin
if (Length(mainform.AppRecArray) = 0) then if (Length(mainform.AppRecArray) = 0) then
begin begin
@ -280,9 +299,4 @@ begin
bDetailsChanged := False; bDetailsChanged := False;
end; end;
procedure Tconfigform.grp_updateintervalClick(Sender: TObject);
begin
end;
end. end.

View File

@ -7,7 +7,6 @@ object mainform: Tmainform
Caption = 'mainform' Caption = 'mainform'
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow
OnWindowStateChange = FormWindowStateChange OnWindowStateChange = FormWindowStateChange
Position = poScreenCenter Position = poScreenCenter
ShowInTaskBar = stNever ShowInTaskBar = stNever
@ -80,7 +79,7 @@ object mainform: Tmainform
Left = 128 Left = 128
Top = 16 Top = 16
end end
object EventLog1: TEventLog object Logger: TEventLog
AppendContent = False AppendContent = False
LogType = ltFile LogType = ltFile
Active = False Active = False

View File

@ -39,19 +39,21 @@ VERSION HISTORY
0.1.12: Commit to svn 0.1.12: Commit to svn
0.1.13: Updated January 2017 0.1.13: Updated January 2017
Ini filename uses C_PFX Ini filename uses C_PFX
0.1.14: Memory leaks fixed
0.1.15: ??
} }
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils, FileUtil, LazFileUtils,Forms, Controls, Graphics, Dialogs, ExtCtrls, Classes, SysUtils, FileUtil, LazFileUtils, Forms, Dialogs, ExtCtrls,
Menus, uLongTimer, ulazautoupdate, inifiles, eventlog, strUtils, uconfigform Menus, uLongTimer, ulazautoupdate, inifiles, eventlog, strUtils, uconfigform
{$IFDEF WINDOWS}, registry{$ENDIF}; {$IFDEF WINDOWS}, registry{$ENDIF};
type type
{ TAppRec - in-memory storage for all settings } { TAppRec - in-memory storage for all settings }
TAppRec = record TAppRec = record
AppPrettyName: string; AppPrettyName: string;
AppPath: string; AppPath: string;
INIPath: string; INIPath: string;
@ -66,10 +68,10 @@ TAppRec = record
IntervalHour: word; IntervalHour: word;
Update: boolean; Update: boolean;
LastCheckDateTime: TDateTime; LastCheckDateTime: TDateTime;
end; end;
{ Tmainform } { Tmainform }
Tmainform = class(TForm) Tmainform = class(TForm)
Logger: TEventLog; Logger: TEventLog;
idleReminder: TIdleTimer; idleReminder: TIdleTimer;
LazAutoUpdate1: TLazAutoUpdate; LazAutoUpdate1: TLazAutoUpdate;
@ -82,7 +84,6 @@ Tmainform = class(TForm)
TrayIcon1: TTrayIcon; TrayIcon1: TTrayIcon;
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormWindowStateChange(Sender: TObject); procedure FormWindowStateChange(Sender: TObject);
procedure idleReminderTimer(Sender: TObject); procedure idleReminderTimer(Sender: TObject);
procedure LazAutoUpdate1DebugEvent(Sender: TObject; WhereAt, Message: string); procedure LazAutoUpdate1DebugEvent(Sender: TObject; WhereAt, Message: string);
@ -95,7 +96,7 @@ Tmainform = class(TForm)
function UT_DateTimeToStr(TheDate: TDateTime): string; function UT_DateTimeToStr(TheDate: TDateTime): string;
function UT_StrToDate(str: string): TDateTime; function UT_StrToDate(str: string): TDateTime;
private private
{ private declarations } { private declarations }
szImportINIPath: string; szImportINIPath: string;
DebugMode: boolean; DebugMode: boolean;
@ -112,7 +113,7 @@ private
procedure DoLongTimerEvent(Sender: TObject); procedure DoLongTimerEvent(Sender: TObject);
// Do a silent check/install for this AppRecArray member // Do a silent check/install for this AppRecArray member
procedure CheckAndUpdate(ARecIndex: integer); procedure CheckAndUpdate(ARecIndex: integer);
public public
{ public declarations } { public declarations }
INI: TIniFile; INI: TIniFile;
AppRecArray: array of TAppRec; // Dynamic array AppRecArray: array of TAppRec; // Dynamic array
@ -120,12 +121,12 @@ public
iCurrentRecIndex: integer; iCurrentRecIndex: integer;
// Transfers info from AppRecArray to local INI // Transfers info from AppRecArray to local INI
procedure DoWriteAppRecArrayIntoINI; procedure DoWriteAppRecArrayIntoINI;
end; end;
var var
mainform : Tmainform; mainform: Tmainform;
Const const
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
C_OS = 'win'; C_OS = 'win';
{$ELSE} {$ELSE}
@ -137,16 +138,16 @@ Const
C_BITNESS = '64'; C_BITNESS = '64';
{$ENDIF} {$ENDIF}
C_PFX = C_OS + C_BITNESS; C_PFX = C_OS + C_BITNESS;
C_LAUTRayINI = 'lauimport.ini'; C_LAUTRayINI = 'lauimport.ini';
C_INIFilename = 'trayupdater' + C_PFX + '.ini'; C_INIFilename = 'trayupdater' + C_PFX + '.ini';
implementation implementation
resourcestring resourcestring
rs_balloontitle = '%s service'; rs_balloontitle = '%s service';
rs_trayloaded = '%s Loaded'; rs_trayloaded = '%s Loaded';
rs_newversionavailable = 'A new version of %s (v%s) is available'; rs_newversionavailable = 'A new version of %s (v%s) is available';
// TODO: Put all the other strings here // TODO: Put all the other strings here
{$R *.lfm} {$R *.lfm}
@ -154,8 +155,8 @@ rs_newversionavailable = 'A new version of %s (v%s) is available';
procedure Tmainform.DoWriteAppRecArrayIntoINI; procedure Tmainform.DoWriteAppRecArrayIntoINI;
// AppRecArray is an in-memory copy of the INI file // AppRecArray is an in-memory copy of the INI file
var var
i : integer; i: integer;
szSection : string; szSection: string;
begin begin
if High(AppRecArray) = 0 then if High(AppRecArray) = 0 then
Exit; Exit;
@ -192,7 +193,7 @@ procedure Tmainform.DoLongTimerEvent(Sender: TObject);
// All LongTimerArray.OnTimer events go here // All LongTimerArray.OnTimer events go here
// The Tag property is the same as the AppRecArray entry it relates to // The Tag property is the same as the AppRecArray entry it relates to
var var
iTag : integer; iTag: integer;
begin begin
iTag := 0; iTag := 0;
// Assertion check // Assertion check
@ -217,7 +218,7 @@ procedure Tmainform.DoSetupLongTimerArray;
// 2. Iterate through the AppRecArray, setting up a new LongTimer for each element // 2. Iterate through the AppRecArray, setting up a new LongTimer for each element
// 3. Enable the LongTimers for which AppArray.Update=TRUE // 3. Enable the LongTimers for which AppArray.Update=TRUE
var var
i, iArrayElement : integer; i, iArrayElement: integer;
begin begin
// Start with an empty array // Start with an empty array
for i := Low(LongTimerArray) to High(LongTimerArray) do for i := Low(LongTimerArray) to High(LongTimerArray) do
@ -262,7 +263,7 @@ end;
function Tmainform.UT_DateTimeToStr(TheDate: TDateTime): string; function Tmainform.UT_DateTimeToStr(TheDate: TDateTime): string;
var var
frmstg : TFormatSettings; frmstg: TFormatSettings;
// Ensures consitent String dates across platforms // Ensures consitent String dates across platforms
begin begin
//GetLocaleFormatSettings(0, frmstg); //GetLocaleFormatSettings(0, frmstg);
@ -275,7 +276,7 @@ end;
function Tmainform.UT_StrToDate(str: string): TDateTime; function Tmainform.UT_StrToDate(str: string): TDateTime;
var var
frmstg : TFormatSettings; frmstg: TFormatSettings;
// Ensures consitent String dates across platforms // Ensures consitent String dates across platforms
begin begin
//GetLocaleFormatSettings(0, frmstg); //GetLocaleFormatSettings(0, frmstg);
@ -290,9 +291,9 @@ end;
procedure Tmainform.DoReadINIIntoAppRecArray; procedure Tmainform.DoReadINIIntoAppRecArray;
// AppRecArray is an in-memory copy of the INI file // AppRecArray is an in-memory copy of the INI file
var var
SectionStringList : TStringList; SectionStringList: TStringList;
szSection : string; szSection: string;
i, iArrayElement : integer; i, iArrayElement: integer;
begin begin
SetLength(AppRecArray, 0); // Zeros the array SetLength(AppRecArray, 0); // Zeros the array
SectionStringList := TStringList.Create; SectionStringList := TStringList.Create;
@ -354,7 +355,7 @@ end;
procedure Tmainform.PopulateOwnProfile; procedure Tmainform.PopulateOwnProfile;
// Only called when app is first run // Only called when app is first run
var var
szSection, szOSsuffix : string; szSection, szOSsuffix: string;
begin begin
szSection := Application.Title; szSection := Application.Title;
szOSsuffix := LowerCase( szOSsuffix := LowerCase(
@ -399,10 +400,10 @@ function Tmainform.ImportINIFile: boolean;
// Sets Update=TRUE // Sets Update=TRUE
// into C_INIFilename then deletes source ini // into C_INIFilename then deletes source ini
var var
ImportINI : TIniFile; ImportINI: TIniFile;
SectionStringList, SectionContents : TStringList; SectionStringList, SectionContents: TStringList;
i : integer; i: integer;
szSection, szKey, szLocation, szAppPath : string; szSection, szKey, szLocation, szAppPath: string;
begin begin
{TODO: Preserve user Logtimer settings?} {TODO: Preserve user Logtimer settings?}
Result := False; Result := False;
@ -513,7 +514,7 @@ end;
procedure Tmainform.mnu_AboutClick(Sender: TObject); procedure Tmainform.mnu_AboutClick(Sender: TObject);
var var
sz : string; sz: string;
begin begin
LazAutoUpdate1.ResetAppVersion; LazAutoUpdate1.ResetAppVersion;
sz := Application.Title + ' system tray application' + LineEnding; sz := Application.Title + ' system tray application' + LineEnding;
@ -547,7 +548,7 @@ end;
procedure Tmainform.mnu_startAtOSStartUpClick(Sender: TObject); procedure Tmainform.mnu_startAtOSStartUpClick(Sender: TObject);
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
var var
Reg : TRegistry; Reg: TRegistry;
{$ENDIF} {$ENDIF}
begin begin
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
@ -665,13 +666,15 @@ begin
DebugMode := True DebugMode := True
else else
DebugMode := False; DebugMode := False;
{$IFDEF DEBUGMODE}DebugMode := True;{$ENDIF} {$IFDEF DEBUGMODE}
DebugMode := True;
{$ENDIF}
// Initialise the App's main INI file // Initialise the App's main INI file
Try try
INI := TIniFile.Create(GetAppConfigDirUTF8(False) + C_INIFilename); INI := TIniFile.Create(GetAppConfigDirUTF8(False) + C_INIFilename);
Except except
sleep(4000); sleep(4000);
If (INI = Nil) then if (INI = nil) then
INI := TIniFile.Create(GetAppConfigDirUTF8(False) + C_INIFilename); INI := TIniFile.Create(GetAppConfigDirUTF8(False) + C_INIFilename);
end; end;
INI.CacheUpdates := False; INI.CacheUpdates := False;
@ -702,7 +705,8 @@ begin
// Logger.Identification := Application.Title; // Logger.Identification := Application.Title;
// Fetch the location of any trayicon INI on the users system // Fetch the location of any trayicon INI on the users system
szImportINIPath := GetAppConfigDirUTF8(False, True); szImportINIPath := GetAppConfigDirUTF8(False, True);
szImportINIPath := AnsiReplaceText(szImportINIPath, Application.Title, 'updatehm' + C_PFX); szImportINIPath := AnsiReplaceText(szImportINIPath, Application.Title,
'updatehm' + C_PFX);
szImportINIPath := AppendPathDelim(szImportINIPath) + C_LAUTRayINI; szImportINIPath := AppendPathDelim(szImportINIPath) + C_LAUTRayINI;
if DebugMode then if DebugMode then
Logger.Debug('szImportINIPath=' + szImportINIPath); Logger.Debug('szImportINIPath=' + szImportINIPath);
@ -724,13 +728,9 @@ begin
mnu_SelfCheck.Visible := DebugMode; mnu_SelfCheck.Visible := DebugMode;
end; end;
procedure Tmainform.FormShow(Sender: TObject);
begin
end;
procedure Tmainform.FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure Tmainform.FormCloseQuery(Sender: TObject; var CanClose: boolean);
var var
i : integer; i: integer;
begin begin
if LazAutoUpdate1.DownloadInprogress then if LazAutoUpdate1.DownloadInprogress then
begin begin
@ -738,11 +738,14 @@ begin
CanClose := False; CanClose := False;
end end
else else
// Clean up memory No leaks (V0.1.14)
begin begin
if DebugMode then if DebugMode then
begin
Logger.Log('User closed application'); Logger.Log('User closed application');
if DebugMode then
Logger.Active := False; Logger.Active := False;
FreeAndNil(Logger);
end;
CanClose := True; CanClose := True;
end; end;
if CanClose then if CanClose then
@ -754,6 +757,9 @@ begin
LongTimerArray[i].Enabled := False; LongTimerArray[i].Enabled := False;
FreeAndNil(LongTimerArray[i]); FreeAndNil(LongTimerArray[i]);
end; end;
SetLength(AppRecArray, 0);
FreeAndNil(AppRecArray);
FreeAndNil(INI);
end; end;
end; end;