[fpc-devel] patch to call DoneKeyboard in the exitproc of the drivers unit

Nikolay Nikolov nickysn at users.sourceforge.net
Sun Aug 23 15:14:55 CEST 2009


On 08/16/2009 04:29 PM, Daniƫl Mantione wrote:
> I can see the issue with abnormal program exits, but I disabled it 
> because calling it twice had unintended effects. So we need to verify 
> we don't break anything.
Well, I can think of 2 thing that could go wrong:

- DoneKeyboard is called _after_ DoneVideo (not before) in 
TApplication.Done. I'm not sure if the order matters. We can switch them 
in the Drivers unit ExitProc also.
- If DoneKeyboard blows up with a run time error, during a normal 
TApplication.Done call, then the ExitProc of the Drivers unit will call 
DoneKeyboard again, which in turn will call SysDoneKeyboard again, 
because the previous SysDoneKeyboard didn't finish and the 
KeyboardInitialized flag wasn't set to false. I don't know if this might 
have unintended side effects. This is all in rtl/inc/keyboard.inc:

procedure DoneKeyboard;

begin

   If KeyboardInitialized then

     begin

     If Assigned(CurrentKeyBoardDriver.DoneDriver) Then

       CurrentKeyBoardDriver.DoneDriver();

     KeyboardInitialized:=False;

     end;

end;


If that's the case, we can add a flag KeyboardInitialized in Drivers, 
add a check inside Drivers.DoneKeyboard and set it to false _before_ the 
actual call to Keyboard.DoneKeyboard.



More information about the fpc-devel mailing list