Comments (17)
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.
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.
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.
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.
I will send it to you by email :)
from ston.
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.
Note: #testStoreAndLoadAllSystemSettings fails as well
from ston.
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
.
from ston.
Yes, I saw that as well, that is indeed wrong.
from ston.
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.
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...
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.
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.
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.
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.
Super, I can work with that. Thank you!
from ston.
3df1ea0 should fix the problem
from ston.
I can confirm this is fixed.
Thanks for the swift fix!
from ston.
Related Issues (20)
- Error parsing the empty symbol HOT 1
- 32-bit Unicode characters not encoded/decoded correctly HOT 9
- Some tests fail on Squeak HOT 11
- Serializing & materializing a Bag with duplicate elements fails HOT 7
- Shouldn't Text class >> #fromSton: be on 'Ston-Text-Support' ? HOT 2
- Why appending a Z on Date with UTC offset? HOT 3
- Symbols containing non-byte characters are not correctly serialized HOT 2
- Improve the definition of legal characters in class names HOT 4
- STON is not cycle-proof HOT 19
- Cleanup newlines and blanks in "STON" packages
- Floating point numbers not materializing correctly HOT 1
- Color values lose precision when serialized HOT 1
- Special floating point values cause errors on materialization HOT 1
- Improve method comments HOT 3
- STON incorrectly converts instances of Text HOT 5
- STON incorrectly converts instances of Interval HOT 5
- Bug writing instances of SmallDictionary HOT 8
- Avoid writing variables with nil as value? HOT 3
- Bug reading instances of Text HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ston.