disabling idle handler during TApplication error handling

git-svn-id: trunk@6793 -
This commit is contained in:
mattias 2005-02-17 18:54:04 +00:00
parent 8d74a139b2
commit 9ed4753dc8
2 changed files with 35 additions and 7 deletions

View File

@ -860,6 +860,8 @@ type
ahtUserInput ahtUserInput
); );
{ TApplication }
TApplication = class(TCustomApplication) TApplication = class(TCustomApplication)
private private
FApplicationHandlers: array[TApplicationHandlerType] of TMethodList; FApplicationHandlers: array[TApplicationHandlerType] of TMethodList;
@ -877,6 +879,7 @@ type
FHintTimerType: TAppHintTimerType; FHintTimerType: TAppHintTimerType;
FHintWindow: THintWindow; FHintWindow: THintWindow;
FIcon: TIcon; FIcon: TIcon;
FIdleLockCount: Integer;
FFormList: TList; FFormList: TList;
FMainForm : TForm; FMainForm : TForm;
FMouseControl: TControl; FMouseControl: TControl;
@ -962,6 +965,8 @@ type
procedure Run; procedure Run;
procedure ShowException(E: Exception); override; procedure ShowException(E: Exception); override;
procedure Terminate; override; procedure Terminate; override;
procedure DisableIdleHandler;
procedure EnableIdleHandler;
procedure NotifyUserInputHandler(Msg: Cardinal); procedure NotifyUserInputHandler(Msg: Cardinal);
procedure NotifyKeyDownBeforeHandler(Sender: TObject; procedure NotifyKeyDownBeforeHandler(Sender: TObject;
var Key: Word; Shift: TShiftState); var Key: Word; Shift: TShiftState);

View File

@ -303,19 +303,22 @@ procedure TApplication.Idle;
var var
Done: Boolean; Done: Boolean;
begin begin
DoFreeReleaseComponents; if FIdleLockCount=0 then
DoFreeReleaseComponents;
MouseIdle(GetControlAtMouse); MouseIdle(GetControlAtMouse);
Done := True; Done := True;
if Assigned(FOnIdle) then FOnIdle(Self, Done); if (FIdleLockCount=0) and Assigned(FOnIdle) then FOnIdle(Self, Done);
NotifyIdleHandler; NotifyIdleHandler;
if Done then begin if Done then begin
// wait till something happens // wait till something happens
DoIdleActions; if (FIdleLockCount=0) then
DoIdleActions;
Include(FFlags,AppWaiting); Include(FFlags,AppWaiting);
Exclude(FFlags,AppIdleEndSent); Exclude(FFlags,AppIdleEndSent);
InterfaceObject.WaitMessage; InterfaceObject.WaitMessage;
DoOnIdleEnd; if (FIdleLockCount=0) then
DoOnIdleEnd;
Exclude(FFlags,AppWaiting); Exclude(FFlags,AppWaiting);
end; end;
end; end;
@ -1063,9 +1066,14 @@ begin
if (Msg <> '') and (Msg[length(Msg)] <> '.') then Msg := Msg + '.'; if (Msg <> '') and (Msg[length(Msg)] <> '.') then Msg := Msg + '.';
if (not Terminated) if (not Terminated)
and (Self<>nil) then begin and (Self<>nil) then begin
MsgResult:=MessageBox(PChar(Msg+#13#13'Press Ok to ignore.' DisableIdleHandler;
+#13'Press Cancel to stop the program.'),PChar(GetTitle), try
MB_OKCANCEL + MB_ICONERROR); 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 if MsgResult<>mrOk then begin
Include(FFlags,AppNoExceptionMessages); Include(FFlags,AppNoExceptionMessages);
HaltingProgram:=true; HaltingProgram:=true;
@ -1085,6 +1093,18 @@ begin
InterfaceObject.AppTerminate; InterfaceObject.AppTerminate;
end; 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; procedure TApplication.NotifyUserInputHandler;
@ -1357,6 +1377,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $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 Revision 1.98 2005/02/17 18:48:24 mattias
extented error message of TApplication extented error message of TApplication