🚨 Free login profile handles on read or write errors
This commit is contained in:
+18
-12
@@ -128,11 +128,14 @@ begin
|
|||||||
if InputQuery('Save profile', 'Enter the name of the profile:', profileName) then
|
if InputQuery('Save profile', 'Enter the name of the profile:', profileName) then
|
||||||
begin
|
begin
|
||||||
profile := TIniFile.Create(FProfilePath + profileName + '.ini');
|
profile := TIniFile.Create(FProfilePath + profileName + '.ini');
|
||||||
profile.WriteString('Connection', 'Host', edHost.Text);
|
try
|
||||||
profile.WriteInteger('Connection', 'Port', edPort.Value);
|
profile.WriteString('Connection', 'Host', edHost.Text);
|
||||||
profile.WriteString('Connection', 'Username', edUsername.Text);
|
profile.WriteInteger('Connection', 'Port', edPort.Value);
|
||||||
profile.WriteString('Data', 'Path', edData.Text);
|
profile.WriteString('Connection', 'Username', edUsername.Text);
|
||||||
profile.Free;
|
profile.WriteString('Data', 'Path', edData.Text);
|
||||||
|
finally
|
||||||
|
profile.Free;
|
||||||
|
end;
|
||||||
cbProfile.ItemIndex := cbProfile.Items.IndexOf(profileName);
|
cbProfile.ItemIndex := cbProfile.Items.IndexOf(profileName);
|
||||||
if cbProfile.ItemIndex = -1 then
|
if cbProfile.ItemIndex = -1 then
|
||||||
begin
|
begin
|
||||||
@@ -149,13 +152,16 @@ begin
|
|||||||
if cbProfile.ItemIndex > -1 then
|
if cbProfile.ItemIndex > -1 then
|
||||||
begin
|
begin
|
||||||
profile := TIniFile.Create(FProfilePath + cbProfile.Text + '.ini');
|
profile := TIniFile.Create(FProfilePath + cbProfile.Text + '.ini');
|
||||||
edHost.Text := profile.ReadString('Connection', 'Host', '');
|
try
|
||||||
edPort.Value := profile.ReadInteger('Connection', 'Port', 2597);
|
edHost.Text := profile.ReadString('Connection', 'Host', '');
|
||||||
edUsername.Text := profile.ReadString('Connection', 'Username', '');
|
edPort.Value := profile.ReadInteger('Connection', 'Port', 2597);
|
||||||
edPassword.Text := '';
|
edUsername.Text := profile.ReadString('Connection', 'Username', '');
|
||||||
edData.Text := profile.ReadString('Data', 'Path', '');
|
edPassword.Text := '';
|
||||||
edPassword.SetFocus;
|
edData.Text := profile.ReadString('Data', 'Path', '');
|
||||||
profile.Free;
|
edPassword.SetFocus;
|
||||||
|
finally
|
||||||
|
profile.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user