[Lazarus] Check if an abstract method is implemented or not

Fei Valentain fielamia at gmail.com
Thu Jan 24 09:18:57 CET 2013


Hi, I don't test it in fp. But in Delphi I just create virtual method with
empty body in this situation.
24.01.2013 15:11 пользователь "xrfang" <xrfang at gmail.com> написал:

> Hi All,
>
> I wrote a TPainter abstract class, and a TPaintRect class.  In the
> TPaintRect class I have this code:
>
> procedure TPaintRect.OnMouseEnter(Sender: TObject);
> var
>   i: Integer;
>   p: TPainter;
> begin
>   for i := 0 to painters.Count - 1 do begin
>     p := TPainter(painters.Objects[i]);
>     try
>       p.OnMouseEnter(Sender);
>     except on EAbstractError do ; end;
>   end;
>   if Assigned(FOnMouseEnter) then FOnMouseEnter(Sender);
> end;
>
> While running in IDE, the program will crash because OnMouseEnter is
> abstract.
>
> My problems are:
>
> 1) As I already wrapped it with try-except, I hope it won't trigger IDE
> exception. But even I turn off "Notify on Lazarus Exception" in debugger
> options it still pops up, and the popup said RunError(211), NOT
> EAbstractError.  The program runs well outside of IDE.
>
> 2) Is there a way to detect if an abstract method is implemented or not,
> without trying to call it and try...except?
>
> Thanks,
> Shannon
>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130124/87fdbb16/attachment-0003.html>


More information about the Lazarus mailing list