"Calling Application.QueueAsyncCall for Execute methods on show of forms, so the forms can finish showing before data is retrieved and processed."

git-svn-id: trunk@17168 -
This commit is contained in:
darius 2008-11-01 11:15:21 +00:00
parent 85fcacb7ea
commit 97f2b268a1
4 changed files with 32 additions and 32 deletions

View File

@ -44,7 +44,7 @@ type
FRepoPath: string;
public
{ public declarations }
procedure Execute;
procedure Execute(Data: PtrInt);
end;
procedure ShowSVNDiffFrm(ASwitches, ARepoPath: string);
@ -72,7 +72,7 @@ end;
procedure TSVNDiffFrm.FormShow(Sender: TObject);
begin
Caption := Format(rsLazarusSVNDiff, [FRepoPath]);
Execute;
Application.QueueAsyncCall(@Execute, 0);
end;
procedure TSVNDiffFrm.FormCreate(Sender: TObject);
@ -86,7 +86,7 @@ begin
SVNDiffMemo.Lines.SaveToFile(SaveDialog.FileName);
end;
procedure TSVNDiffFrm.Execute;
procedure TSVNDiffFrm.Execute(Data: PtrInt);
var
AProcess: TProcess;
BytesRead: LongInt;

View File

@ -89,7 +89,7 @@ type
procedure UpdateLogListView;
public
{ public declarations }
procedure Execute;
procedure Execute(Data: PtrInt);
end;
procedure ShowSVNLogFrm(ARepoPath: string);
@ -182,7 +182,7 @@ end;
procedure TSVNLogFrm.FormShow(Sender: TObject);
begin
Caption := Format(rsLazarusSVNLog, [FRepoPath]);
Execute;
Application.QueueAsyncCall(@Execute, 0);
end;
procedure TSVNLogFrm.LogListViewSelectItem(Sender: TObject; Item: TListItem;
@ -243,7 +243,7 @@ end;
procedure TSVNLogFrm.RefreshButtonClick(Sender: TObject);
begin
Execute;
Execute(0);
end;
procedure TSVNLogFrm.mnuShowDiffClick(Sender: TObject);
@ -284,7 +284,7 @@ begin
LogList.Free;
end;
procedure TSVNLogFrm.Execute;
procedure TSVNLogFrm.Execute(Data: PtrInt);
var
M: TMemoryStream;
Doc: TXMLDocument;

View File

@ -49,7 +49,7 @@ type
{ private declarations }
FRepoPath: string;
SVNStatus: TSVNStatus;
procedure UpdateFilesListView;
procedure UpdateFilesListView(Data: PtrInt);
public
{ public declarations }
end;
@ -81,7 +81,7 @@ begin
SVNStatus.Sort(siChecked, sdAscending);
Caption := Format('%s - %s...', [FRepoPath, rsLazarusSVNCommit]);
UpdateFilesListView;
Application.QueueAsyncCall(@UpdateFilesListView, 0);
end;
procedure TSVNStatusFrm.mnuShowDiffClick(Sender: TObject);
@ -138,7 +138,7 @@ begin
8: SVNStatus.ReverseSort(siDate);
end;
UpdateFilesListView;
UpdateFilesListView(0);
end;
procedure TSVNStatusFrm.SVNFileListViewSelectItem(Sender: TObject;
@ -147,7 +147,7 @@ begin
PSVNStatusItem(SVNStatus.List.Items[Item.Index])^.Checked:=Item.Checked;
end;
procedure TSVNStatusFrm.UpdateFilesListView;
procedure TSVNStatusFrm.UpdateFilesListView(Data: PtrInt);
var
i: integer;
StatusItem : PSVNStatusItem;

View File

@ -47,7 +47,7 @@ type
procedure ProcessSVNUpdateOutput(var MemStream: TMemoryStream; var BytesRead: LongInt);
public
{ public declarations }
procedure Execute;
procedure Execute(Data: PtrInt);
end;
procedure ShowSVNUpdateFrm(ARepoPath: string);
@ -85,7 +85,7 @@ end;
procedure TSVNUpdateFrm.FormShow(Sender: TObject);
begin
Caption := Format(rsLazarusSVNUpdate, [FRepoPath]);
Execute;
Application.QueueAsyncCall(@Execute, 0);
end;
procedure TSVNUpdateFrm.mnuShowDiffClick(Sender: TObject);
@ -152,36 +152,36 @@ begin
Invalidate;
end;
procedure TSVNUpdateFrm.Execute;
procedure TSVNUpdateFrm.Execute(Data: PtrInt);
var
M: TMemoryStream;
P: TProcess;
AProcess: TProcess;
n: LongInt;
MemStream: TMemoryStream;
BytesRead: LongInt;
begin
SVNUpdateListView.Clear;
M := TMemoryStream.Create;
MemStream := TMemoryStream.Create;
BytesRead := 0;
P := TProcess.Create(nil);
P.CommandLine := SVNExecutable + ' update ' + FRepoPath + ' --non-interactive';
debugln('TSVNUpdateFrm.Execute CommandLine ' + P.CommandLine);
P.Options := [poUsePipes, poStdErrToOutput];
P.ShowWindow := swoHIDE;
P.Execute;
AProcess := TProcess.Create(nil);
AProcess.CommandLine := SVNExecutable + ' update ' + FRepoPath + ' --non-interactive';
debugln('TSVNUpdateFrm.Execute CommandLine ' + AProcess.CommandLine);
AProcess.Options := [poUsePipes, poStdErrToOutput];
AProcess.ShowWindow := swoHIDE;
AProcess.Execute;
while P.Running do
while AProcess.Running do
begin
// make sure we have room
M.SetSize(BytesRead + READ_BYTES);
MemStream.SetSize(BytesRead + READ_BYTES);
// try reading it
n := P.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
n := AProcess.Output.Read((MemStream.Memory + BytesRead)^, READ_BYTES);
if n > 0
then begin
Inc(BytesRead, n);
ProcessSVNUpdateOutput(m, BytesRead);
ProcessSVNUpdateOutput(MemStream, BytesRead);
end
else begin
// no data, wait 100 ms
@ -192,18 +192,18 @@ begin
// read last part
repeat
// make sure we have room
M.SetSize(BytesRead + READ_BYTES);
MemStream.SetSize(BytesRead + READ_BYTES);
// try reading it
n := P.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
n := AProcess.Output.Read((MemStream.Memory + BytesRead)^, READ_BYTES);
if n > 0
then begin
Inc(BytesRead, n);
ProcessSVNUpdateOutput(m, BytesRead);
ProcessSVNUpdateOutput(MemStream, BytesRead);
end;
until n <= 0;
P.Free;
M.Free;
AProcess.Free;
MemStream.Free;
end;
initialization