Skip to content

Commit

Permalink
Issue #821: don't stack prompts to reload a loaded SQL file after mul…
Browse files Browse the repository at this point in the history
…tiple external changes
  • Loading branch information
ansgarbecker committed May 6, 2021
1 parent b62a743 commit 1fac5d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/main.pas
Expand Up @@ -78,6 +78,7 @@ TQueryTab = class(TComponent)
FMemoFilename: String;
FQueryRunning: Boolean;
FLastChange: TDateTime;
FDirectoryWatchNotficationRunning: Boolean;
procedure SetMemoFilename(Value: String);
procedure SetQueryRunning(Value: Boolean);
procedure TimerLastChangeOnTimer(Sender: TObject);
Expand Down Expand Up @@ -13957,6 +13958,11 @@ procedure TQueryTab.DirectoryWatchNotify(const Sender: TObject; const Action: TW
IsCurrentFile: Boolean;
begin
// Notification about file changes in loaded file's directory

if FDirectoryWatchNotficationRunning then
Exit;
FDirectoryWatchNotficationRunning := True;

IsCurrentFile := DirectoryWatch.Directory + FileName = MemoFilename;
case Action of
waRemoved:
Expand Down Expand Up @@ -13984,6 +13990,7 @@ procedure TQueryTab.DirectoryWatchNotify(const Sender: TObject; const Action: TW
end;

end;
FDirectoryWatchNotficationRunning := False;
end;


Expand All @@ -13993,13 +14000,17 @@ procedure TQueryTab.MemofileModifiedTimerNotify(Sender: TObject);
OldCursor: TBufferCoord;
begin
(Sender as TTimer).Enabled := False;
if FDirectoryWatchNotficationRunning then
Exit;
FDirectoryWatchNotficationRunning := True;
if MessageDialog(_('Reload file?'), f_('File was modified from outside: %s', [MemoFilename]), mtConfirmation, [mbYes, mbCancel]) = mrYes then begin
OldCursor := Memo.CaretXY;
OldTopLine := Memo.TopLine;
LoadContents(MemoFilename, True, nil);
Memo.CaretXY := OldCursor;
Memo.TopLine := OldTopLine;
end;
FDirectoryWatchNotficationRunning := False;
end;


Expand Down

0 comments on commit 1fac5d7

Please sign in to comment.