diff --git a/components/codetools/ide/codyidentifiersdlg.pas b/components/codetools/ide/codyidentifiersdlg.pas index b81ea417e8..331ad5fc29 100644 --- a/components/codetools/ide/codyidentifiersdlg.pas +++ b/components/codetools/ide/codyidentifiersdlg.pas @@ -624,14 +624,15 @@ begin end; end; - if ChangeStamp<>OldChangeStamp then begin + if fLoaded and (ChangeStamp<>OldChangeStamp) then begin if (fTimer=nil) and (not fClosing) then begin fTimer:=TTimer.Create(nil); - fTimer.Interval:=SaveIntervalInS*1000; fTimer.OnTimer:=@OnTimer; end; - if fTimer<>nil then + if fTimer<>nil then begin + fTimer.Interval:=SaveIntervalInS*1000; fTimer.Enabled:=true; + end; end; end; finally @@ -640,17 +641,28 @@ begin end; end else if fCheckFiles<>nil then begin CheckFiles; - end else begin - // nothing to do, maybe it's time to load the database - if fStartTime=0 then - fStartTime:=Now - else if (fLoadSaveThread=nil) and (not fLoaded) - and (Abs(Now-fStartTime)*86400>=LoadAfterStartInS) then - StartLoadSaveThread; end; - Done:=fQueuedTools.Count=0; - if Done then + Done:= fQueuedTools.Count=0; + if Done then begin IdleConnected:=false; + + if (not fLoaded) and (fLoadSaveThread=nil) then begin + // nothing to do, maybe it's time to load the database + if (Abs(Now-fStartTime)*86400>=LoadAfterStartInS) then begin + StartLoadSaveThread; + end + else begin + if (fTimer=nil) then begin + fTimer:=TTimer.Create(nil); + fTimer.OnTimer:=@OnTimer; + end; + if fTimer<>nil then begin + fTimer.Interval:=Max(10, LoadAfterStartInS*1000 - Trunc(Now-fStartTime)*86400); + fTimer.Enabled:=true; + end; + end; + end; + end; end; procedure TCodyUnitDictionary.WaitForThread; @@ -787,6 +799,7 @@ begin CodeToolBoss.AddHandlerToolTreeChanging(@ToolTreeChanged); LazarusIDE.AddHandlerOnIDEClose(@OnIDEClose); CodyOptions.AddHandlerApply(@OnApplyOptions); + fStartTime:=Now; end; destructor TCodyUnitDictionary.Destroy;