diff --git a/lcl/forms.pp b/lcl/forms.pp index fbff0c6ac6..f22cf99625 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -860,6 +860,8 @@ type ahtUserInput ); + { TApplication } + TApplication = class(TCustomApplication) private FApplicationHandlers: array[TApplicationHandlerType] of TMethodList; @@ -877,6 +879,7 @@ type FHintTimerType: TAppHintTimerType; FHintWindow: THintWindow; FIcon: TIcon; + FIdleLockCount: Integer; FFormList: TList; FMainForm : TForm; FMouseControl: TControl; @@ -962,6 +965,8 @@ type procedure Run; procedure ShowException(E: Exception); override; procedure Terminate; override; + procedure DisableIdleHandler; + procedure EnableIdleHandler; procedure NotifyUserInputHandler(Msg: Cardinal); procedure NotifyKeyDownBeforeHandler(Sender: TObject; var Key: Word; Shift: TShiftState); diff --git a/lcl/include/application.inc b/lcl/include/application.inc index 00ab5532b4..8d99b2ef38 100644 --- a/lcl/include/application.inc +++ b/lcl/include/application.inc @@ -303,19 +303,22 @@ procedure TApplication.Idle; var Done: Boolean; begin - DoFreeReleaseComponents; + if FIdleLockCount=0 then + DoFreeReleaseComponents; MouseIdle(GetControlAtMouse); Done := True; - if Assigned(FOnIdle) then FOnIdle(Self, Done); + if (FIdleLockCount=0) and Assigned(FOnIdle) then FOnIdle(Self, Done); NotifyIdleHandler; if Done then begin // wait till something happens - DoIdleActions; + if (FIdleLockCount=0) then + DoIdleActions; Include(FFlags,AppWaiting); Exclude(FFlags,AppIdleEndSent); InterfaceObject.WaitMessage; - DoOnIdleEnd; + if (FIdleLockCount=0) then + DoOnIdleEnd; Exclude(FFlags,AppWaiting); end; end; @@ -1063,9 +1066,14 @@ begin if (Msg <> '') and (Msg[length(Msg)] <> '.') then Msg := Msg + '.'; if (not Terminated) and (Self<>nil) then begin - MsgResult:=MessageBox(PChar(Msg+#13#13'Press Ok to ignore.' - +#13'Press Cancel to stop the program.'),PChar(GetTitle), - MB_OKCANCEL + MB_ICONERROR); + DisableIdleHandler; + try + MsgResult:=MessageBox(PChar(Msg+#13#13'Press Ok to ignore.' + +#13'Press Cancel to stop the program.'),PChar(GetTitle), + MB_OKCANCEL + MB_ICONERROR); + finally + EnableIdleHandler; + end; if MsgResult<>mrOk then begin Include(FFlags,AppNoExceptionMessages); HaltingProgram:=true; @@ -1085,6 +1093,18 @@ begin InterfaceObject.AppTerminate; end; +procedure TApplication.DisableIdleHandler; +begin + inc(FIdleLockCount); +end; + +procedure TApplication.EnableIdleHandler; +begin + if FIdleLockCount<=0 then + RaiseGDBException('TApplication.EnableIdleHandler'); + dec(FIdleLockCount); +end; + {------------------------------------------------------------------------------ procedure TApplication.NotifyUserInputHandler; @@ -1357,6 +1377,9 @@ end; { ============================================================================= $Log$ + Revision 1.99 2005/02/17 18:54:04 mattias + disabling idle handler during TApplication error handling + Revision 1.98 2005/02/17 18:48:24 mattias extented error message of TApplication