[Lazarus] SIGSEGV with Debug only

Martin lazarus at mfriebe.de
Fri Mar 30 18:49:18 CEST 2012

On 30/03/2012 17:14, Daniel Simoes de Ameida wrote:
> Martin,
> I use a Tab Style interface <http://blog.djsystem.com.br/>... (TDI)... 
> so, I change the Owner/Parent in this function:
>   APage            := TFormPage.Create(nbForms) ;  // This will call 
> TFormPage.SetAForm

> procedure TFormPage.SetAForm(const AValue : TForm) ;
> begin
>   fsAForm := AValue ;
>   Caption := fsAForm.Caption;
>   Color   := fsAForm.Color;
>   fsAForm.BorderStyle := bsNone ;
>   fsAForm.Align       := alClient ;
>   // Change  Aform Owner and Parent
>   fsAForm.Parent := Self;
>   ChangeOwner(fsAForm, Self);
>   //  AForm.FreeNotification(APage);

I can't tell you 100% certain if this is related, but there is a chance 
it is to do with  http://bugs.freepascal.org/view.php?id=21458

Setting the Owner of a component, does call Notify with opRemove  and 
that breaks the FreeNotification system.

Whenever the LCL sets a component to know about another it uses 
FreeNotification. So if one of the 2 is destroyed, the other one is 
informed and wiss not attempt to access the destroyed component.

That also happens for anchors(since the 2 anchored components know about 
each other, they need to know, if one is destroyed)

Due to the bug I mentioned, if you chang the owner, those notifications 
may no longer work. Depending on the order of calls and who knows whom, 
that can cause such a crash.

Do you need to change the owner, or can you live with changing the 
parent only?

The parent should be enough for displaying it.

One of the things the owner will do, is clean up: if the owner is 
destroyed, so is the owned component.
Maybe you can own things by the application?
      APage            := TFormPage.Create(Application) ;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120330/c7f46094/attachment-0003.html>

More information about the Lazarus mailing list