mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 12:39:23 +02:00
cody: dictionary: free FTimer on IDE close
git-svn-id: trunk@33800 -
This commit is contained in:
parent
9183713468
commit
0dc1aff308
@ -81,6 +81,7 @@ type
|
|||||||
fCritSec: TRTLCriticalSection;
|
fCritSec: TRTLCriticalSection;
|
||||||
fLoaded: boolean; // has loaded the file
|
fLoaded: boolean; // has loaded the file
|
||||||
fStartTime: TDateTime;
|
fStartTime: TDateTime;
|
||||||
|
fClosing: boolean;
|
||||||
procedure SetIdleConnected(AValue: boolean);
|
procedure SetIdleConnected(AValue: boolean);
|
||||||
procedure SetLoadAfterStartInS(AValue: integer);
|
procedure SetLoadAfterStartInS(AValue: integer);
|
||||||
procedure SetLoadSaveError(AValue: string);
|
procedure SetLoadSaveError(AValue: string);
|
||||||
@ -90,6 +91,7 @@ type
|
|||||||
procedure WaitForThread;
|
procedure WaitForThread;
|
||||||
procedure OnTimer(Sender: TObject);
|
procedure OnTimer(Sender: TObject);
|
||||||
function StartLoadSaveThread: boolean;
|
function StartLoadSaveThread: boolean;
|
||||||
|
procedure OnIDEClose(Sender: TObject);
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -347,13 +349,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if ChangeStamp<>OldChangeStamp then begin
|
if ChangeStamp<>OldChangeStamp then begin
|
||||||
if fTimer=nil then begin
|
if (fTimer=nil) and (not fClosing) then begin
|
||||||
fTimer:=TTimer.Create(nil);
|
fTimer:=TTimer.Create(nil);
|
||||||
fTimer.Interval:=SaveIntervalInS*1000;
|
fTimer.Interval:=SaveIntervalInS*1000;
|
||||||
fTimer.OnTimer:=@OnTimer;
|
fTimer.OnTimer:=@OnTimer;
|
||||||
end;
|
end;
|
||||||
//debugln(['TCodyUnitDictionary.OnIdle starting timer: ms=',fTimer.Interval]);
|
if fTimer<>nil then
|
||||||
fTimer.Enabled:=true;
|
fTimer.Enabled:=true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -389,7 +391,8 @@ end;
|
|||||||
procedure TCodyUnitDictionary.OnTimer(Sender: TObject);
|
procedure TCodyUnitDictionary.OnTimer(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if StartLoadSaveThread then
|
if StartLoadSaveThread then
|
||||||
fTimer.Enabled:=false;
|
if fTimer<>nil then
|
||||||
|
fTimer.Enabled:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodyUnitDictionary.GetFilename: string;
|
function TCodyUnitDictionary.GetFilename: string;
|
||||||
@ -400,6 +403,7 @@ end;
|
|||||||
function TCodyUnitDictionary.StartLoadSaveThread: boolean;
|
function TCodyUnitDictionary.StartLoadSaveThread: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
if (Self=nil) or fClosing then exit;
|
||||||
if (Application=nil) or (CodyUnitDictionary=nil) then exit;
|
if (Application=nil) or (CodyUnitDictionary=nil) then exit;
|
||||||
//debugln(['TCodyUnitDictionary.StartLoadSaveThread ',fLoadSaveThread<>nil]);
|
//debugln(['TCodyUnitDictionary.StartLoadSaveThread ',fLoadSaveThread<>nil]);
|
||||||
BeginCritSec;
|
BeginCritSec;
|
||||||
@ -416,6 +420,12 @@ begin
|
|||||||
fLoadSaveThread.Start;
|
fLoadSaveThread.Start;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCodyUnitDictionary.OnIDEClose(Sender: TObject);
|
||||||
|
begin
|
||||||
|
fClosing:=true;
|
||||||
|
FreeAndNil(fTimer);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCodyUnitDictionary.SetIdleConnected(AValue: boolean);
|
procedure TCodyUnitDictionary.SetIdleConnected(AValue: boolean);
|
||||||
begin
|
begin
|
||||||
if FIdleConnected=AValue then Exit;
|
if FIdleConnected=AValue then Exit;
|
||||||
@ -459,10 +469,12 @@ begin
|
|||||||
InitCriticalSection(fCritSec);
|
InitCriticalSection(fCritSec);
|
||||||
fQueuedTools:=TAVLTree.Create;
|
fQueuedTools:=TAVLTree.Create;
|
||||||
CodeToolBoss.AddHandlerToolTreeChanging(@ToolTreeChanged);
|
CodeToolBoss.AddHandlerToolTreeChanging(@ToolTreeChanged);
|
||||||
|
LazarusIDE.AddHandlerOnIDEClose(@OnIDEClose);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCodyUnitDictionary.Destroy;
|
destructor TCodyUnitDictionary.Destroy;
|
||||||
begin
|
begin
|
||||||
|
fClosing:=true;
|
||||||
CodeToolBoss.RemoveHandlerToolTreeChanging(@ToolTreeChanged);
|
CodeToolBoss.RemoveHandlerToolTreeChanging(@ToolTreeChanged);
|
||||||
FreeAndNil(fTimer);
|
FreeAndNil(fTimer);
|
||||||
WaitForThread;
|
WaitForThread;
|
||||||
|
Loading…
Reference in New Issue
Block a user