Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Stream Load serialization fired twice
Stream Load serialization fired twice [message #61328] Wed, 25 December 2024 23:56 Go to next message
luoganda is currently offline  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 #61330 is a reply to message #61328] Thu, 26 December 2024 18:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14260
Registered: November 2005
Ultimate Member
luoganda wrote on Wed, 25 December 2024 23:56
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.


The first one is to backup current data so that they can be restored in the event that loading fails...
Re: Stream Load serialization fired twice [message #61333 is a reply to message #61328] Fri, 27 December 2024 14:01 Go to previous messageGo to next message
luoganda is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14260
Registered: November 2005
Ultimate Member
luoganda wrote on Fri, 27 December 2024 14:01
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?


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 #61434 is a reply to message #61328] Tue, 11 February 2025 01:06 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 214
Registered: November 2016
Experienced Member
Functionality 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.
Re: Stream Load serialization fired twice [message #61436 is a reply to message #61434] Tue, 11 February 2025 18:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14260
Registered: November 2005
Ultimate Member
luoganda wrote on Tue, 11 February 2025 01:06
Functionality 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&)

Re: Stream Load serialization fired twice [message #61437 is a reply to message #61328] Tue, 11 February 2025 21:09 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 214
Registered: November 2016
Experienced Member
Func there is described perfectly!

It is of course not described(or pointed out) in LoadFromFile - that's why i newer saw it.

Ok, since it's not much away from LoadFromFile and on the same page,
there is no need to pointing that out.

Still, i don't recommend moving this to archive or delete,
since there may be others checking the same thing.
Re: Stream Load serialization fired twice [message #61438 is a reply to message #61437] Tue, 11 February 2025 22:24 Go to previous message
mirek is currently offline  mirek
Messages: 14260
Registered: November 2005
Ultimate Member
luoganda wrote on Tue, 11 February 2025 21:09
Func there is described perfectly!

It is of course not described(or pointed out) in LoadFromFile - that's why i newer saw it.

Ok, since it's not much away from LoadFromFile and on the same page,
there is no need to pointing that out.

Still, i don't recommend moving this to archive or delete,
since there may be others checking the same thing.


The idea is that it refers back via link. Which currently does not work, on TODO list...

Mirek
Previous Topic: Doubt with Buffer<> of a trivially destructible type
Next Topic: GetSmartTextSize() fails with QTF text
Goto Forum:
  


Current Time: Sun Jun 01 13:29:21 CEST 2025

Total time taken to generate the page: 0.01639 seconds