Code Monkey home page Code Monkey logo

Comments (17)

jbrichau avatar jbrichau commented on July 30, 2024

Confirmed this by reverting to commit f685fb3 which is before the introduction of the Color class>fromSton: implementation. In that version, the scenario does not bug.

from ston.

svenvc avatar svenvc commented on July 30, 2024

Hmm, I do not fully understand, in my 7.0.3 with the latest STON, I get:

(Color r: 0.25 g: 0.5 b: 0.75) in: [ :color | STON toString: { color. color } ].
 "'[Color{#red:0.25,#green:0.5,#blue:0.75,#alpha:1.0},@2]'"
(Color r: 0.25 g: 0.5 b: 0.75) in: [ :color | STON fromString: (STON toString: { color. color }) ].

The second expression works.

AFAIU this works.

Do you see an error in STON or in STON usage ?
Maybe the stored preference is incompatible with the loading STON ?

from ston.

jbrichau avatar jbrichau commented on July 30, 2024

Yes, those snippets work. The problem only arises if the instance of Color is 'referenced' in the STON file.

This happens in the settings of Pharo. I do not have smaller reproducible scenario, but by debugging the store/load of the settings of a virgin Pharo image with latest STON, I got to this problem.

Yes, I make sure to remove the old settings file before testing this. I always do a 'store' and then a 'load', after which it goes wrong.

from ston.

svenvc avatar svenvc commented on July 30, 2024

The snippet is using a reference (the #== object is used twice, second time it is references using @2).

Can you upload the whole STON file ?

from ston.

jbrichau avatar jbrichau commented on July 30, 2024

I will send it to you by email :)

from ston.

svenvc avatar svenvc commented on July 30, 2024

I can reproduce the error in a clean image.

However, even though STON is used to save the settings, it does so in mysterious ways.

In any case, I can do

(StartupPreferencesLoader preferencesVersionFolder / 'system-settings.ston') asFileReference readStreamDo: [ :in | STON fromStream: in ].

so basically, STON can reload the saved preferences. And as far as I can see the preferences are OK.

So we have to figure out what goes wrong where. I never looked at that code.

from ston.

svenvc avatar svenvc commented on July 30, 2024

Note: #testStoreAndLoadAllSystemSettings fails as well

from ston.

jbrichau avatar jbrichau commented on July 30, 2024

I executed the code snippet in your previous message.
In my understanding, the deserialization is not correct because the value of the setting should be an instance of Color rather than Dictionary.

settings-deserialize-debug

from ston.

svenvc avatar svenvc commented on July 30, 2024

Yes, I saw that as well, that is indeed wrong.

from ston.

svenvc avatar svenvc commented on July 30, 2024

I am obviously missing something, but referring to the same color does work:

(Color r: 0.25 g: 0.5 b: 0.75) in: [ :color | STON toString: { StoredSetting new settingNodeIdentifier: #One; realValue: color. StoredSetting new settingNodeIdentifier: #One; realValue: color } ].

And this can be read back:

(Color r: 0.25 g: 0.5 b: 0.75) in: [ :color | STON fromString: (STON toString: { StoredSetting new settingNodeIdentifier: #One; realValue: color. StoredSetting new settingNodeIdentifier: #One; realValue: color }) ].

I can't see where the Dictionary comes from ...

from ston.

jbrichau avatar jbrichau commented on July 30, 2024

The dictionary is stored in the references index of the reader because the implementation of Color class>>fromSton: invokes parseSimpleValue, which calls parseMap who stores the dictionary...

Screenshot 2019-06-05 at 17 07 39

You can get the same debugger when putting the following code in STONReader>>storeReference: and loading the system-settings.ston I sent you.

...
	index = 76 ifTrue:[ self halt] .
...

from ston.

svenvc avatar svenvc commented on July 30, 2024

I used a Conditional Breakpoint to arrive at the same place.

But still, higher up the stack at #parseObject you can see that reference 75 will be set to the Color object itself.

I am still looking for a simpler, more isolated example separate from the settings.

from ston.

jbrichau avatar jbrichau commented on July 30, 2024

Here is one:

| color1 color2 |
color1 := (Color r: 0.25 g: 0.5 b: 0.75 alpha: 10).
color2 := (Color red).
STON fromString: (STON toString: { StoredSetting new settingNodeIdentifier: #One; realValue: color1. StoredSetting new settingNodeIdentifier: #Two; realValue: color2 . StoredSetting new settingNodeIdentifier: #Three; realValue: color2. }).

You will see that the realValue of the setting #Three is the object of setting #Two.

from ston.

jbrichau avatar jbrichau commented on July 30, 2024

More stripped down:

| color1 color2 |
color1 := (Color r: 0.25 g: 0.5 b: 0.75 alpha: 10).
color2 := (Color red).
STON fromString: (STON toString: { color1. color2 . color2 }).

from ston.

svenvc avatar svenvc commented on July 30, 2024

Super, I can work with that. Thank you!

from ston.

svenvc avatar svenvc commented on July 30, 2024

3df1ea0 should fix the problem

from ston.

jbrichau avatar jbrichau commented on July 30, 2024

I can confirm this is fixed.
Thanks for the swift fix!

from ston.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.