Zitat von Michael Van Canneyt <[EMAIL PROTECTED]>:

>
>
> On Fri, 28 Mar 2008, Micha Nelissen wrote:
>
> > Michael Van Canneyt wrote:
> > > It is used in streaming in the classes unit; the streaming mechanism
> checks
> > > the actual
> > > value against this value: if it is the same, the value is not streamed.
> >
> > FYI: so before streaming, the "streamer" has to reset the values to their
> > defaults to stream properly. Unfortenately, there is no function to do
> this,
> > and it's usually done in constructor. Therefore streaming twice does not
> work
> > properly.
>
> This is not correct.
>
> The default value is the value at create time and remains fixed during the
> lifetime of the component. It has no influence on the number of times you
> stream a component.

Theoretically yes.
Practically it works this way:
TWriter writes a value if it differs from the 'default'. The 'default' is
1. if there is a stored function, and it returns false, then the current value
is a default.
2. if there is an ancestor, then the current value of the ancestor
3. the 'default' constant of the property.

So, it is not always possible to find out if _a_ value is default.
You can only find out if the _current_ value is default.

And even worse:
This is only true for normal properties. The DefineProperties can do nearly
anything.

Conclusion:
In general you can not 'reset' an arbitrary component.
Graeme's SetDefaults could be extended to apply all ancestor streams. Then it
would probably set the defaults for 99% of all properties correct, assuming
that the properties define good stored functions, good constructor values and
good default constants.


Mattias

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to