You've already forked lazarus-ccr
0.1.13.0: Renamed TPackageData -> TUpdatePackageData (GetMem)
Renamed TPackageFiles -> TUpdatePackageFiles (GetMem) Comment out Self.AutoAdjustLayout line in Form.Create (GetMem) Removed StrUtils from uses (minesadorada) Fixed memory leaks with CFG and slErrorList (minesadorada) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5419 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
<UseVersionInfo Value="True"/>
|
||||
<AutoIncrementBuild Value="True"/>
|
||||
<MinorVersionNr Value="1"/>
|
||||
<RevisionNr Value="12"/>
|
||||
<RevisionNr Value="13"/>
|
||||
<StringTable Comments="Buld configured for Win Linux and Darwin" FileDescription="An editor for OnlinePackageManager update JSON files" InternalName="jsoneditor" LegalCopyright="(c)2016 usernames lainz and minesadorada @ forum.lazarus.freepascal.org" LegalTrademarks="GPL code" OriginalFilename="jsoneditor" ProductName="Lazarus and Freepascal" ProductVersion="1.x and 3.x"/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="5">
|
||||
@ -51,6 +51,7 @@
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
|
@ -4,13 +4,13 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="Win64"/>
|
||||
<Units Count="13">
|
||||
<Units Count="14">
|
||||
<Unit0>
|
||||
<Filename Value="jsonpackage.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<CursorPos Y="30"/>
|
||||
<UsageCount Value="57"/>
|
||||
<UsageCount Value="61"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -20,12 +20,12 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="730"/>
|
||||
<CursorPos X="32" Y="770"/>
|
||||
<UsageCount Value="57"/>
|
||||
<TopLine Value="349"/>
|
||||
<CursorPos X="3" Y="354"/>
|
||||
<UsageCount Value="61"/>
|
||||
<Bookmarks Count="2">
|
||||
<Item0 Y="458" ID="1"/>
|
||||
<Item1 Y="728"/>
|
||||
<Item0 Y="473" ID="1"/>
|
||||
<Item1 Y="742"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -33,7 +33,7 @@
|
||||
<Unit2>
|
||||
<Filename Value="ugenericcollection.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="57"/>
|
||||
<UsageCount Value="61"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="D:\Lazarusprojects\golfml\egacalculator\source\umainform.pas"/>
|
||||
@ -100,138 +100,150 @@
|
||||
<Unit11>
|
||||
<Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/>
|
||||
<UnitName Value="Grids"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="10428"/>
|
||||
<CursorPos X="29" Y="10452"/>
|
||||
<UsageCount Value="12"/>
|
||||
<UsageCount Value="13"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="C:\NewPascalDarwin\fpc\rtl\objpas\classes\classesh.inc"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="517"/>
|
||||
<CursorPos X="3" Y="478"/>
|
||||
<UsageCount Value="12"/>
|
||||
<UsageCount Value="13"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="X:\MainForm\MainForm\umain.pas"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="200"/>
|
||||
<CursorPos X="21" Y="383"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
</Units>
|
||||
<JumpHistory Count="29" HistoryIndex="28">
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="13" Column="50" TopLine="22"/>
|
||||
<Caret Line="188" Column="19" TopLine="148"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="31" Column="50" TopLine="22"/>
|
||||
<Caret Line="189" Column="19" TopLine="149"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="65" Column="20" TopLine="25"/>
|
||||
<Caret Line="190" Column="19" TopLine="150"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="73" Column="79" TopLine="33"/>
|
||||
<Caret Line="214" Column="18" TopLine="174"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="100" Column="23" TopLine="60"/>
|
||||
<Caret Line="397" Column="21" TopLine="357"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="105" Column="22" TopLine="65"/>
|
||||
<Caret Line="403" Column="21" TopLine="363"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="185" Column="19" TopLine="145"/>
|
||||
<Caret Line="464" Column="70" TopLine="424"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="188" Column="19" TopLine="148"/>
|
||||
<Caret Line="486" Column="21" TopLine="446"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="189" Column="19" TopLine="149"/>
|
||||
<Caret Line="598" Column="32" TopLine="558"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="190" Column="19" TopLine="150"/>
|
||||
<Caret Line="600" Column="37" TopLine="560"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="214" Column="18" TopLine="174"/>
|
||||
<Caret Line="601" Column="23" TopLine="561"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="397" Column="21" TopLine="357"/>
|
||||
<Caret Line="620" Column="77" TopLine="580"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="403" Column="21" TopLine="363"/>
|
||||
<Caret Line="623" Column="37" TopLine="583"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="464" Column="70" TopLine="424"/>
|
||||
<Caret Line="624" Column="23" TopLine="585"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="486" Column="21" TopLine="446"/>
|
||||
<Caret Line="628" Column="33" TopLine="589"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="598" Column="32" TopLine="558"/>
|
||||
<Caret Line="629" Column="42" TopLine="590"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="600" Column="37" TopLine="560"/>
|
||||
<Caret Line="631" Column="37" TopLine="592"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="601" Column="23" TopLine="561"/>
|
||||
<Caret Line="632" Column="23" TopLine="593"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="620" Column="77" TopLine="580"/>
|
||||
<Caret Line="636" Column="65" TopLine="597"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="623" Column="37" TopLine="583"/>
|
||||
<Caret Line="638" Column="37" TopLine="599"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="624" Column="23" TopLine="585"/>
|
||||
<Caret Line="639" Column="23" TopLine="600"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="628" Column="33" TopLine="589"/>
|
||||
<Caret Line="710" Column="61" TopLine="670"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="629" Column="42" TopLine="590"/>
|
||||
<Caret Line="397" TopLine="360"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="631" Column="37" TopLine="592"/>
|
||||
<Caret Line="441" Column="5" TopLine="414"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="632" Column="23" TopLine="593"/>
|
||||
<Caret Line="444" Column="42" TopLine="141"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="636" Column="65" TopLine="597"/>
|
||||
<Caret Line="386" Column="27" TopLine="377"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="638" Column="37" TopLine="599"/>
|
||||
<Caret Line="431" Column="18" TopLine="417"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="639" Column="23" TopLine="600"/>
|
||||
<Caret Line="367" Column="18" TopLine="363"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="710" Column="61" TopLine="670"/>
|
||||
<Caret Line="36" Column="71" TopLine="10"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="700" TopLine="682"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
</CONFIG>
|
||||
|
Binary file not shown.
@ -28,7 +28,12 @@ unit umain;
|
||||
0.1.9.0: Error check for duplicate lpk entries (minesadorada)
|
||||
0.1.10.0: Exception handling for Load + Save (minesadorada)
|
||||
0.1.11.0: Cleaned up code formatting etc. (minesadorada)
|
||||
0.1.12.0: Renamed DownloadURL to DownloadZipURL (minesadorada)
|
||||
0.1.12.0: Rename Global DownloadURL to DownloadZipURL (minesadorada)
|
||||
0.1.13.0: Renamed TPackageData -> TUpdatePackageData (GetMem)
|
||||
Renamed TPackageFiles -> TUpdatePackageFiles (GetMem)
|
||||
Comment out Self.AutoAdjustLayout line in Form.Create (GetMem)
|
||||
Removed StrUtils from uses (minesadorada)
|
||||
Fixed memory leaks with CFG and slErrorList (minesadorada)
|
||||
}
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
@ -38,16 +43,16 @@ interface
|
||||
uses
|
||||
Classes, Forms, Controls, StdCtrls, Menus, ActnList, StdActns, Grids,
|
||||
Graphics, Buttons, fileutil, LazFileUtils, fileinfo, ugenericcollection, fpjsonrtti,
|
||||
Dialogs, StrUtils, LCLTranslator, PopupNotifier, SysUtils, inifiles,
|
||||
Dialogs, LCLTranslator, PopupNotifier, SysUtils, inifiles,
|
||||
lclintf, lclVersion;
|
||||
|
||||
type
|
||||
|
||||
{ TPackage }
|
||||
|
||||
{ TPackageFiles }
|
||||
{ TUpdatePackageFiles }
|
||||
|
||||
TPackageFiles = class(TCollectionItem)
|
||||
TUpdatePackageFiles = class(TCollectionItem)
|
||||
private
|
||||
FName: string;
|
||||
FVersion: string;
|
||||
@ -56,11 +61,11 @@ type
|
||||
property Version: string read FVersion write FVersion;
|
||||
end;
|
||||
|
||||
TPackageFilesList = specialize TGenericCollection<TPackageFiles>;
|
||||
TPackageFilesList = specialize TGenericCollection<TUpdatePackageFiles>;
|
||||
|
||||
{ TPackageData }
|
||||
{ TUpdatePackageData }
|
||||
|
||||
TPackageData = class(TPersistent)
|
||||
TUpdatePackageData = class(TPersistent)
|
||||
private
|
||||
FDownloadZipURL: string;
|
||||
FForceUpdate: boolean;
|
||||
@ -75,7 +80,7 @@ type
|
||||
|
||||
TPackage = class(TPersistent)
|
||||
private
|
||||
FPackage: TPackageData;
|
||||
FPackage: TUpdatePackageData;
|
||||
FPackageFiles: TPackageFilesList;
|
||||
public
|
||||
constructor Create;
|
||||
@ -83,7 +88,7 @@ type
|
||||
function LoadFromFile(AFileName: string): boolean;
|
||||
function SaveToFile(AFileName: string): boolean;
|
||||
published
|
||||
property Package: TPackageData read FPackage write FPackage;
|
||||
property Package: TUpdatePackageData read FPackage write FPackage;
|
||||
property PackageFiles: TPackageFilesList read FPackageFiles write FPackageFiles;
|
||||
end;
|
||||
|
||||
@ -145,14 +150,16 @@ type
|
||||
bForceSaveAs, bShowPopupHints, bDisableWarnings, bDirty, bIsVirgin: boolean;
|
||||
sJSONFilePath: string;
|
||||
sUpdateDirectory, sZipDirectory: string;
|
||||
CFG: TIniFile;
|
||||
slErrorList: TStrings;
|
||||
CFG: TIniFile;
|
||||
INIFilePath:String;
|
||||
function ValidationFailed: boolean;
|
||||
procedure CtrlShowPopup(Sender: TObject);
|
||||
procedure CtrlHidePopup(Sender: TObject);
|
||||
procedure CtrlSetUpPopupHandlers;
|
||||
procedure CtrlMakeDirty(Sender: TObject);
|
||||
function FoundADuplicateLPK: boolean;
|
||||
Function CreateUniqueINI(var aCount: integer):Boolean;
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
@ -205,9 +212,9 @@ resourcestring
|
||||
rsThereAreOneO = '- There are one or more .lpk entries with the same name.%s'
|
||||
+ '- Every .lpk entry must have a unique name.';
|
||||
|
||||
{ TPackageData }
|
||||
{ TUpdatePackageData }
|
||||
|
||||
constructor TPackageData.Create;
|
||||
constructor TUpdatePackageData.Create;
|
||||
begin
|
||||
FName := '';
|
||||
FForceUpdate := False;
|
||||
@ -356,42 +363,48 @@ end;
|
||||
|
||||
procedure TfrmMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
CFG.WriteBool('Options', 'Virgin', False);
|
||||
CFG.WriteBool('Options', 'DiableWarnings', bDisableWarnings);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
begin
|
||||
CanClose := True;
|
||||
if bDisableWarnings = True then
|
||||
exit;
|
||||
if bDirty = True then
|
||||
if ((bDirty = True) AND (bDisableWarnings=FALSE)) then
|
||||
begin
|
||||
if MessageDlg(rsFileMayBeUns, mtConfirmation, [mbYes, mbNo], 0, mbNo) = mrNo then
|
||||
CanClose := False;
|
||||
end;
|
||||
CFG.WriteBool('Options', 'Virgin', False);
|
||||
CFG.WriteBool('Options', 'DiableWarnings', bDisableWarnings);
|
||||
CFG.UpdateFile;
|
||||
Application.ProcessMessages;
|
||||
CFG.Free;
|
||||
slErrorList.Free;
|
||||
end;
|
||||
function TfrmMain.CreateUniqueINI(var aCount: integer):Boolean;
|
||||
// Recursively loop until correct INI found, or new one created
|
||||
begin
|
||||
Result:=FALSE;
|
||||
INIFilePath := GetAppConfigFile(False) + IntToStr(aCount);
|
||||
CFG := TIniFile.Create(INIFilePath);
|
||||
CFG.CacheUpdates:=TRUE;
|
||||
if CFG.ReadString('Options', 'AppPath', ProgramDirectory) <> ProgramDirectory then
|
||||
begin
|
||||
FreeAndNil(CFG); // Ditch the old one
|
||||
Inc(aCount);
|
||||
Result:=TRUE;
|
||||
CreateUniqueINI(aCount); // Make a new one
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.FormCreate(Sender: TObject);
|
||||
var
|
||||
sLang, INIFilePath: string;
|
||||
|
||||
procedure CreateUniqueINI(aCount: integer);
|
||||
// Recursively loop until correct INI found, or new one created
|
||||
begin
|
||||
INIFilePath := GetAppConfigFile(False) + IntToStr(aCount);
|
||||
CFG := TIniFile.Create(INIFilePath);
|
||||
if CFG.ReadString('Options', 'AppPath', ProgramDirectory) <> ProgramDirectory then
|
||||
begin
|
||||
CFG.Free; // Ditch the old one
|
||||
Inc(aCount);
|
||||
CreateUniqueINI(aCount); // Make a new one
|
||||
end;
|
||||
end;
|
||||
|
||||
sLang: string;
|
||||
iIniCount:Integer;
|
||||
begin
|
||||
{
|
||||
Self.AutoAdjustLayout(lapAutoAdjustForDPI, Self.DesignTimeDPI,
|
||||
Screen.PixelsPerInch, Self.Width, ScaleX(Self.Width, Self.DesignTimeDPI));
|
||||
}
|
||||
// Enable AutoSize again to get correct Height
|
||||
editName.AutoSize := True;
|
||||
editDownloadZipURL.AutoSize := True;
|
||||
@ -404,9 +417,9 @@ begin
|
||||
stringPackageFiles.Columns[0].Title.Caption := rsLpkFileName;
|
||||
stringPackageFiles.Columns[1].Title.Caption := rsVersion0000;
|
||||
// Defaults
|
||||
slErrorList := TStringList.Create;
|
||||
bForceSaveAs := True;
|
||||
bShowPopupHints := True;
|
||||
slErrorList := TStringList.Create;
|
||||
// Encourage the user to maintain an updates folder
|
||||
sUpdateDirectory := ProgramDirectory + 'updates';
|
||||
if not FileExistsUTF8(sUpdateDirectory) then
|
||||
@ -415,9 +428,11 @@ begin
|
||||
// Enable options persistence
|
||||
// If program location is different, create a new CFG file
|
||||
// Because each component's location might be different
|
||||
CreateUniqueINI(0);
|
||||
CFG.WriteString('Options', 'AppPath', ProgramDirectory);
|
||||
|
||||
iIniCount:=0;
|
||||
If CreateUniqueINI(iIniCount) then
|
||||
CFG.WriteString('Options', 'AppPath', ProgramDirectory);
|
||||
CFG.UpdateFile;
|
||||
ShowMessageFmt('Inifile=%s, Count=%d',[INIFilePath,iIniCount]);
|
||||
// Pop-up hints (show on first run, then not again unless the user chooses)
|
||||
bIsVirgin := CFG.ReadBool('Options', 'Virgin', True);
|
||||
bShowPopupHints := bIsVirgin;
|
||||
@ -682,7 +697,6 @@ end;
|
||||
procedure TfrmMain.SaveAsItemClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
s: string;
|
||||
begin
|
||||
if ValidationFailed then
|
||||
begin
|
||||
@ -780,7 +794,7 @@ end;
|
||||
|
||||
constructor TPackage.Create;
|
||||
begin
|
||||
FPackage := TPackageData.Create;
|
||||
FPackage := TUpdatePackageData.Create;
|
||||
FPackageFiles := TPackageFilesList.Create;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user