[fpc-devel] 0010465: CsSubComponent component properties not streamed

Michael Van Canneyt michael at freepascal.org
Sun Dec 23 22:08:34 CET 2007

On Sun, 23 Dec 2007, Florian Klaempfl wrote:

> Martin Schreiber schrieb:
> > Hi,
> > 
> > Michael Van Canneyt marked my bugreport 10465 with "won't fix", I would like 
> > to discuss the issue in a broader forum.
> > With fixes_2_2 rev. 9006 FPC does not stream published component properties 
> > where the component has CsSubComponent set if the property component is not 
> > owned by the streamed component.
> > Delphi streams CsSubComponent properties independent of ownership.
> What was the reason for the change?

The reason is that Delphi-compatible cannot handle references to subcomponents. 
This 'bug' was fixed during systems by me and Mattias Gaertner.

In particular:

Consider the ActiveControl property of TForm.
The Lazarus TButtonPanel component has buttons as subcomponents (OKButton, CancelButton etc). 

When the ActiveControl property of the form is set to one of these buttons, then the old, 
delphi-compatible code would stream the whole OKButton as ActiveControl. 

This is of course wrong, only a reference to OKButton should be streamed. This is a bug in 
the Delphi streaming mechanism: it cannot correctly handle references to subcomponents.

The OKButton should only be streamed as part of TButtonPanel, not when some other component
references it. The bugfix makes sure this is so, by checking the owner of the subcomponent: 
if this is the same as the instance being streamed (the ButtonPanel instance in this case), 
then the subcomponent is streamed, otherwise a reference is streamed.

All Martin has to do is make sure his subcomponent is owned by the component it is a subcomponent 
of, and his code will function correctly. Since his sample code uses nil as owner, this is a minor
- and Delphi-compatible - change IMHO.


More information about the fpc-devel mailing list