Skip to content

Commit

Permalink
Issue #1717: block too fast and overlapping calls of refresh action, …
Browse files Browse the repository at this point in the history
…to reduce crash probability
  • Loading branch information
ansgarbecker committed Jan 18, 2023
1 parent 498ebfb commit 4358406
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ TMainForm = class(TExtForm)
FFilterTextDatabase,
FFilterTextData: String;
FTreeRefreshInProgress: Boolean;
FRefreshActionDisabledAt: Cardinal;
FDataGridColumnWidthsCustomized: Boolean;
FDataGridLastClickedColumnHeader: Integer;
FDataGridLastClickedColumnLeftPos: Integer;
Expand Down Expand Up @@ -4748,7 +4749,10 @@ procedure TMainForm.actRefreshExecute(Sender: TObject);
begin
// Refresh
// Force data tab update when appropriate.
// Disable refresh action and re-enable in ApplicationOnIdle event
tab1 := PageControlMain.ActivePage;
actRefresh.Enabled := False;
FRefreshActionDisabledAt := GetTickCount;
if ActiveControl = DBtree then
RefreshTree
else if tab1 = tabHost then begin
Expand Down Expand Up @@ -14111,6 +14115,13 @@ procedure TMainForm.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean);
ListTables.SortTree(ListTables.Header.SortColumn, ListTables.Header.SortDirection);
FListTablesSorted := True;
end;

// Re-enable refresh action when application is idle
if (not actRefresh.Enabled) and (FRefreshActionDisabledAt < (GetTickCount - 1000)) then
begin
actRefresh.Enabled := True;
end;

end;


Expand Down

0 comments on commit 4358406

Please sign in to comment.