FIX: Crash on colors.json saving

This commit is contained in:
Alexander Koblov 2023-05-07 17:15:18 +03:00
commit b908cc031c

View file

@ -15,6 +15,8 @@ type
private
FRoot: TJSONObject;
public
constructor Create;
destructor Destroy; override;
procedure SaveToFile(const FileName: String);
procedure LoadFromFile(const FileName: String);
property Root: TJSONObject read FRoot;
@ -27,6 +29,17 @@ uses
{ TJsonConfig }
constructor TJsonConfig.Create;
begin
FRoot:= TJSONObject.Create;
end;
destructor TJsonConfig.Destroy;
begin
inherited Destroy;
FRoot.Free;
end;
procedure TJsonConfig.SaveToFile(const FileName: String);
begin
with TStringListEx.Create do
@ -44,6 +57,7 @@ var
begin
AStream:= TFileStreamEx.Create(FileName, fmOpenRead or fmShareDenyNone);
try
FreeAndNil(FRoot);
FRoot:= GetJSON(AStream, True) as TJSONObject;
finally
AStream.Free;