Skip to content

Commit

Permalink
Issue #746: log result of donor check in log panel, move http request…
Browse files Browse the repository at this point in the history
… from FormCreate to AfterFormCreate, and repaint image after show/hide
  • Loading branch information
ansgarbecker committed Sep 13, 2019
1 parent 65873c9 commit acfc5bc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions source/main.pas
Expand Up @@ -1978,9 +1978,6 @@ procedure TMainForm.FormCreate(Sender: TObject);
FGridCopying := False;
FGridPasting := False;

FHasDonatedDatabaseCheck := nbUnset;
imgDonate.Visible := HasDonated(True) <> nbTrue;

FileEncodings := Explode(',', _('Auto detect (may fail)')+',ANSI,ASCII,Unicode,Unicode Big Endian,UTF-8,UTF-7');

// Detect timezone offset in seconds, once
Expand Down Expand Up @@ -2073,6 +2070,11 @@ procedure TMainForm.AfterFormCreate;
SessionPaths := TStringList.Create;
AppSettings.GetSessionPaths('', SessionPaths);

// Probably hide image
FHasDonatedDatabaseCheck := nbUnset;
imgDonate.Visible := HasDonated(True) <> nbTrue;
imgDonate.Repaint;

// Call user statistics if checked in settings
if AppSettings.ReadBool(asDoUsageStatistics) then begin
try
Expand Down Expand Up @@ -12850,12 +12852,13 @@ function TMainForm.HasDonated(ForceCheck: Boolean): TThreeStateBoolean;
except
on E:Exception do begin
// Try again without SSL. See issue #65
MainForm.LogSQL(E.Message, lcError);
LogSQL(E.Message, lcError);
CheckWebpage.URL := ReplaceRegExpr('^https:', CheckWebpage.URL, 'http:');
CheckWebpage.SendRequest('');
end;
end;
CheckResult := CheckWebpage.LastContent;
LogSQL('Check success response: "'+CheckResult+'"');
rx.Expression := '^\d+$';
if rx.Exec(CheckResult) then begin
if CheckResult = '0' then
Expand All @@ -12865,7 +12868,7 @@ function TMainForm.HasDonated(ForceCheck: Boolean): TThreeStateBoolean;
end;
except
on E:Exception do begin
MainForm.LogSQL(E.Message + sLineBreak + 'Check response: "'+CheckResult+'"', lcError);
LogSQL(E.Message + sLineBreak + 'Check response: "'+CheckResult+'"', lcError);
FHasDonatedDatabaseCheck := nbUnset; // Could have been set before, when ForceCheck=true
end;
end;
Expand Down

0 comments on commit acfc5bc

Please sign in to comment.