[fpc-devel] Bug in trunk?

Michael Van Canneyt michael at freepascal.org
Fri Mar 28 15:37:18 CET 2008



On Fri, 28 Mar 2008, Micha Nelissen wrote:

> Michael Van Canneyt wrote:
> > > 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. 
> 
> Example: suppose a component has been written out that uses the default for a
> certain property X. Now if you do:
> 
> class.X := <some-non-default-value>;
> stream.readstream(class);
> (class.X = <default-value>) is false, while it should be true.

Why should it be true ? 
The specs only say something about writing, not about reading.

It is a misconception to think that you can read a stream
and thus restore a component to it's "original designed state".

The behaviour of reading a component from stream is only well-defined
after it was just created. 

If you want a general streaming mechanism (javabeans like), then you
simply should not use "stored" or "default", then you'll have something
that comes close.

Michael.



More information about the fpc-devel mailing list