|
|
Home » U++ Library support » U++ Core » Stream Load serialization fired twice
Stream Load serialization fired twice [message #61328] |
Wed, 25 December 2024 23:56  |
luoganda
Messages: 214 Registered: November 2016
|
Experienced Member |
|
|
Calling LoadFromFile stream in
"bool Load(Event<Stream&> serialize, Stream& stream, int version){ ..."
calls user function "void XUserClass::Serialize(Stream& s){..." twice.
Once with backup.SetStoring(); flag and once with stream.SetLoading();.
Both are called from Core/Stream.cpp at 1287 in "bool Load(Event<Stream&> serialize, ...".
I don't think this is normal, since user callback is fired twice.
|
|
|
|
Re: Stream Load serialization fired twice [message #61333 is a reply to message #61328] |
Fri, 27 December 2024 14:01   |
luoganda
Messages: 214 Registered: November 2016
|
Experienced Member |
|
|
yes, i though it has something to do with it, but...
* maybe i am wrong - but i didn't notice anything about it in
** documentation(has a potential of 'unknown'/undetectable bugs) - personally i didn't know about it until i saw it in debugger.
** With that i mostly mean - app could get confused, "why is there IsStoring set if i am on start and only loading something"?
** I think i saw someone once asking about similar 'bug' about stream loading - 80% chance it was about this.
* when user is loading something, there is no need for 'backup yet(it could also be a read-only system on which this would probably fail in debug mode - on release it would go 'bug undetected')
If this can not be corrected(then 'new' documented feature is a must!!), how can one(in user callback) tell:
* if it is called from Load... by backup.Serialize with SetStoring flag set? (firing 1st time?)
* -||- but fired 2nd time - with SetLoading flag set?
* if is it really called from Load... if Storing is set?
[Updated on: Fri, 27 December 2024 14:44] Report message to a moderator
|
|
|
Re: Stream Load serialization fired twice [message #61425 is a reply to message #61333] |
Tue, 04 February 2025 08:40   |
 |
mirek
Messages: 14260 Registered: November 2005
|
Ultimate Member |
|
|
luoganda wrote on Fri, 27 December 2024 14:01yes, i though it has something to do with it, but...
* maybe i am wrong - but i didn't notice anything about it in
** documentation(has a potential of 'unknown'/undetectable bugs) - personally i didn't know about it until i saw it in debugger.
** With that i mostly mean - app could get confused, "why is there IsStoring set if i am on start and only loading something"?
** I think i saw someone once asking about similar 'bug' about stream loading - 80% chance it was about this.
* when user is loading something, there is no need for 'backup yet(it could also be a read-only system on which this would probably fail in debug mode - on release it would go 'bug undetected')
If this can not be corrected(then 'new' documented feature is a must!!), how can one(in user callback) tell:
* if it is called from Load... by backup.Serialize with SetStoring flag set? (firing 1st time?)
* -||- but fired 2nd time - with SetLoading flag set?
* if is it really called from Load... if Storing is set?
Well, Load does what it does. If you need anything else with serialisation, you can just take stream and call Serialize directly - nothing wrong with that.
(Actually, if you do not want the functionaly that Load provides, what is point of using it? Just create read stream and invoke Serialize).
|
|
|
|
Re: Stream Load serialization fired twice [message #61436 is a reply to message #61434] |
Tue, 11 February 2025 18:20   |
 |
mirek
Messages: 14260 Registered: November 2005
|
Ultimate Member |
|
|
luoganda wrote on Tue, 11 February 2025 01:06Functionality is a plus,
but - like i said - it just is not mentioned in the docs
and the app behaved a little weird - till i saw the "added bonus" in debuger,
since - depends how app is written(IsStoring/IsLoading may be used for some hokusPokus) - that
IsStoring/IsLoading may affect all later if/else/etc doings.
If app uses those two calls in Loading state of an app:
App must then not depend on that calls too much(once IsStoring will ret true and another IsLoading will also ret true),
so if app makes some hokus-pokus(mostly usually meaning app is not written correctly) - it must use it's own logic(it's own IsLoading/IsStoring).
That is not much of a problem though.
When user knows that there is a hidden backup(plus),
that makes a whole different story.
For upp this is mostly not a problem since source is there:),
but for closed-software that bonus not being mentioned could be an issue.
"(Actually, if you do not want the functionaly that Load provides, what is point of using it? Just create read stream and invoke Serialize)."
For convenience, instead of making 2/3lines - there is one.
It is actually documented.
https://www.ultimatepp.org/src$Core$SerializationUtils$en-us .html#::Load(Callback1%3CStream&%3E,Stream&)
|
|
|
|
|
Goto Forum:
Current Time: Sun Jun 01 13:29:21 CEST 2025
Total time taken to generate the page: 0.01639 seconds
|
|
|