mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-05 00:16:06 +02:00
lazbuild: fixed freeing views
git-svn-id: trunk@45393 -
This commit is contained in:
parent
49de54d716
commit
b2dca3d504
@ -490,7 +490,7 @@ type
|
|||||||
procedure LeaveCriticalSection; virtual;
|
procedure LeaveCriticalSection; virtual;
|
||||||
property Thread: TThread read FThread write FThread;
|
property Thread: TThread read FThread write FThread;
|
||||||
procedure ConsistencyCheck; virtual;
|
procedure ConsistencyCheck; virtual;
|
||||||
procedure AutoFree; // free if not in use
|
procedure AutoFree; // (only main thread) free if not in use
|
||||||
|
|
||||||
property Title: string read FTitle write SetTitle;
|
property Title: string read FTitle write SetTitle;
|
||||||
property Hint: string read FHint write FHint; // this hint is shown in About dialog
|
property Hint: string read FHint write FHint; // this hint is shown in About dialog
|
||||||
@ -605,6 +605,7 @@ type
|
|||||||
procedure Clear; virtual; abstract; // terminate + free all tools
|
procedure Clear; virtual; abstract; // terminate + free all tools
|
||||||
property Items[Index: integer]: TAbstractExternalTool read GetItems; default;
|
property Items[Index: integer]: TAbstractExternalTool read GetItems; default;
|
||||||
function Add(Title: string): TAbstractExternalTool; virtual; abstract;
|
function Add(Title: string): TAbstractExternalTool; virtual; abstract;
|
||||||
|
function IndexOf(Tool: TAbstractExternalTool): integer; virtual; abstract;
|
||||||
procedure ConsistencyCheck; virtual;
|
procedure ConsistencyCheck; virtual;
|
||||||
procedure EnterCriticalSection; virtual; abstract;
|
procedure EnterCriticalSection; virtual; abstract;
|
||||||
procedure LeaveCriticalSection; virtual; abstract;
|
procedure LeaveCriticalSection; virtual; abstract;
|
||||||
|
@ -35,7 +35,7 @@ unit ExtTools;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, math, process, Pipes, contnrs, UTF8Process,
|
Classes, SysUtils, math, process, Pipes, UTF8Process,
|
||||||
LazFileUtils,
|
LazFileUtils,
|
||||||
// Codetools
|
// Codetools
|
||||||
FileProcs, CodeToolsStructs,
|
FileProcs, CodeToolsStructs,
|
||||||
@ -87,7 +87,7 @@ type
|
|||||||
|
|
||||||
TLazExtToolConsole = class(TComponent)
|
TLazExtToolConsole = class(TComponent)
|
||||||
private
|
private
|
||||||
fViews: TObjectList; // list of TLazExtToolConsoleView
|
fViews: TFPList; // list of TLazExtToolConsoleView
|
||||||
function GetViews(Index: integer): TLazExtToolConsoleView;
|
function GetViews(Index: integer): TLazExtToolConsoleView;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@ -181,6 +181,7 @@ type
|
|||||||
constructor Create(aOwner: TComponent); override;
|
constructor Create(aOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function Add(Title: string): TAbstractExternalTool; override;
|
function Add(Title: string): TAbstractExternalTool; override;
|
||||||
|
function IndexOf(Tool: TAbstractExternalTool): integer; override;
|
||||||
property MaxProcessCount: integer read FMaxProcessCount write FMaxProcessCount;
|
property MaxProcessCount: integer read FMaxProcessCount write FMaxProcessCount;
|
||||||
procedure Work;
|
procedure Work;
|
||||||
function FindNextToolToExec: TExternalTool;
|
function FindNextToolToExec: TExternalTool;
|
||||||
@ -221,18 +222,21 @@ end;
|
|||||||
constructor TLazExtToolConsole.Create(AOwner: TComponent);
|
constructor TLazExtToolConsole.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
fViews:=TObjectList.Create(true);
|
fViews:=TFPList.Create;
|
||||||
ExtToolConsole:=Self;
|
ExtToolConsole:=Self;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TLazExtToolConsole.Destroy;
|
destructor TLazExtToolConsole.Destroy;
|
||||||
begin
|
begin
|
||||||
Clear;
|
Clear;
|
||||||
|
FreeAndNil(fViews);
|
||||||
ExtToolConsole:=nil;
|
ExtToolConsole:=nil;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazExtToolConsole.Clear;
|
procedure TLazExtToolConsole.Clear;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
while FindUnfinishedView<>nil do begin
|
while FindUnfinishedView<>nil do begin
|
||||||
if Application<>nil then
|
if Application<>nil then
|
||||||
@ -241,7 +245,12 @@ begin
|
|||||||
CheckSynchronize;
|
CheckSynchronize;
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
end;
|
end;
|
||||||
fViews.Clear;
|
for i:=Count-1 downto 0 do begin
|
||||||
|
if i>=Count then continue;
|
||||||
|
Views[i].Free;
|
||||||
|
end;
|
||||||
|
if Count>0 then
|
||||||
|
raise Exception.Create('TLazExtToolConsole.Clear: some views failed to free');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazExtToolConsole.CreateView(Tool: TAbstractExternalTool
|
function TLazExtToolConsole.CreateView(Tool: TAbstractExternalTool
|
||||||
@ -507,13 +516,14 @@ begin
|
|||||||
|
|
||||||
EnterCriticalSection;
|
EnterCriticalSection;
|
||||||
try
|
try
|
||||||
for i:=0 to ViewCount-1 do begin
|
for i:=ViewCount-1 downto 0 do begin
|
||||||
|
if i>=ViewCount then continue;
|
||||||
View:=Views[i];
|
View:=Views[i];
|
||||||
if ErrorMessage<>'' then
|
if ErrorMessage<>'' then
|
||||||
View.SummaryMsg:=ErrorMessage
|
View.SummaryMsg:=ErrorMessage
|
||||||
else
|
else
|
||||||
View.SummaryMsg:='Success';
|
View.SummaryMsg:='Success';
|
||||||
View.InputClosed;
|
View.InputClosed; // this might delete the view
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
LeaveCriticalSection;
|
LeaveCriticalSection;
|
||||||
@ -600,9 +610,9 @@ destructor TExternalTool.Destroy;
|
|||||||
begin
|
begin
|
||||||
EnterCriticalSection;
|
EnterCriticalSection;
|
||||||
try
|
try
|
||||||
|
FStage:=etsDestroying;
|
||||||
if Thread is TExternalToolThread then
|
if Thread is TExternalToolThread then
|
||||||
TExternalToolThread(Thread).Tool:=nil;
|
TExternalToolThread(Thread).Tool:=nil;
|
||||||
FStage:=etsDestroying;
|
|
||||||
FreeAndNil(FProcess);
|
FreeAndNil(FProcess);
|
||||||
FreeAndNil(FWorkerOutput);
|
FreeAndNil(FWorkerOutput);
|
||||||
FreeAndNil(fExecuteBefore);
|
FreeAndNil(fExecuteBefore);
|
||||||
@ -947,7 +957,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TExternalTool.WaitForExit;
|
procedure TExternalTool.WaitForExit;
|
||||||
|
var
|
||||||
|
MyTools: TIDEExternalTools;
|
||||||
begin
|
begin
|
||||||
|
MyTools:=Tools;
|
||||||
repeat
|
repeat
|
||||||
EnterCriticalSection;
|
EnterCriticalSection;
|
||||||
try
|
try
|
||||||
@ -956,11 +969,15 @@ begin
|
|||||||
finally
|
finally
|
||||||
LeaveCriticalSection;
|
LeaveCriticalSection;
|
||||||
end;
|
end;
|
||||||
|
// call synchronized tasks, this might free this tool
|
||||||
if MainThreadID=ThreadID then
|
if MainThreadID=ThreadID then
|
||||||
if Application<>nil then
|
if Application<>nil then
|
||||||
Application.ProcessMessages
|
Application.ProcessMessages
|
||||||
else
|
else
|
||||||
CheckSynchronize;
|
CheckSynchronize;
|
||||||
|
// check if this tool still exists
|
||||||
|
if MyTools.IndexOf(Self)<0 then exit;
|
||||||
|
// still running => wait
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
until false;
|
until false;
|
||||||
end;
|
end;
|
||||||
@ -1270,6 +1287,11 @@ begin
|
|||||||
fItems.Add(Result);
|
fItems.Add(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TExternalTools.IndexOf(Tool: TAbstractExternalTool): integer;
|
||||||
|
begin
|
||||||
|
Result:=fItems.IndexOf(Tool);
|
||||||
|
end;
|
||||||
|
|
||||||
function TExternalTools.ParserCount: integer;
|
function TExternalTools.ParserCount: integer;
|
||||||
begin
|
begin
|
||||||
Result:=fParsers.Count;
|
Result:=fParsers.Count;
|
||||||
|
Loading…
Reference in New Issue
Block a user