Skip to content
Permalink
Browse files

Issue #746: log result of donor check in log panel, move http request…

… from FormCreate to AfterFormCreate, and repaint image after show/hide
  • Loading branch information...
ansgarbecker committed Sep 13, 2019
1 parent 65873c9 commit acfc5bc1750d0afffb941a80f2a683c694d51ab7
Showing with 8 additions and 5 deletions.
  1. +8 −5 source/main.pas
@@ -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
@@ -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
@@ -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
@@ -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;

0 comments on commit acfc5bc

Please sign in to comment.
You can’t perform that action at this time.