Hello, I’m using a JSON from a perspective view to build a sort of wizard.
I made some input box binding to some properties of the JSON and everything is ok, then I have two buttons with some scripts and I’d like to understand what’s going on.
Pressing the first button I read the JSON and I pass it as an argument to a script function like this :
obj = self.view.getChild("root").custom.porta #<-- json from perspective
func1.Go(obj)
func2.Go(obj)
func1 : modify state of JSON
func2 : print out JSON obj
I notice that func2 seams to work on a not updated JSON, and if I print the state I can clearly see that the attributes are not being modified from func1.
However, if I check the JSON state from the GUI I can see that the attributes are changed.
If i repeat the process, i can see on the output that the JSON is updated from the last call, so i end up always with one iteration of delay.
Button 1 :
obj = self.view.getChild("root").custom.porta #<-- json from perspective
func1.Go(obj)
sleep(10)
func2.Go(obj)
Button 2 :
obj = self.view.getChild("root").custom.porta #<-- json from perspective
system.perspective.print(obj)
Clicking the first button and then the second one, I can see JSON printed out is correctly being modified from func1, however after 10 seconds I got the printed text from func2 JSON printed is not updated.
I noticed some strange behavior when working with arrays too.
Am I missing something or am I not supposed to work in this way?
Adding a note :
A way to reproduce is to create a JSON like this one :
First button Script :
obj = self.view.custom.test
obj['val_1']['index'] +=1
obj['val_1']['index'] +=1
obj['val_1']['index'] +=1
obj['val_1']['index'] +=1
obj['val_1']['index'] +=1
index get incremented by 1.
Second Button :
self.view.custom.test.val_1.index += 1
self.view.custom.test.val_1.index += 1
self.view.custom.test.val_1.index += 1
It work as expected.
Thank you