[fpc-pascal] methods of an object to create others objects

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Jul 7 15:37:55 CEST 2010


On 7 July 2010 15:25, Andrew Brunner <andrew.t.brunner at gmail.com> wrote:
>
> procedure TObj1.Free;
> begin
>  Disk1.Unmount; <<< The disk object is missing now b/c a network failure;
>  Inherited Destroy;
> end;
>
> procedure TObj1.Free;
> begin
>  Try
>    Disk1.Unmount;
>  Except
>    On E:Exception do begin
>       // Some case stuff here
>    end;
>  end;
>  Inherited Destroy;
> end;
>
> In my example... Your code would blow out an application.  With my
> exception handling the app would continue on as normal with no
> problems.

With the exception of a possible memory leak in case Disk1.Unmount was
supposed to free up some resources. And if your app is something that
runs 24/7, that is a *huge* problem! Eventually you will run out of
memory and the whole thing will come crumbling down (and maybe even
cause more damage).


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list