FlowCanvas Forums › Support › If an exception is launched the values of ValueInput are losts [2.9.0, 2.9.2]
If an exception is launched the values of ValueInput are losts.
For reproduce the bug I add a variable “duration” of type ValueInput in class ANDMERGE, initialized this value from inspector the graph and launch a generic exception. After I remove the exception, the value in variable “duration” is lost. What I expect the value is persisted.
I have prepared a video that reproduces the problem:
I tested this bug in 2.9.0 and 2.9.2 (I had read that a similar bug was there in the 2.9.1)
Hello,
Just to explain what is going on, if you open up FlowNode.cs and take a look at the “GatherPorts” method, you will see that “RegisterPorts” is called within, and right after that, the “DeserializeInputPortValues” is called. If of course an exception is thrown within the RegisterPorts implementation, the “DeserializeInputPortValues” is never called and thus the port values (of this particular node) are lost since the graph is then serialized back.
There is an exception handling per node registration (so that if one node throws an exception the rest proceed normally), but to avoid what is happening in a per-node basis when an exception is thrown, there will need to exist yet another exception handling. Changing the “GatherPorts” method to be like the following will effectively work the way you suggest (make port serialization perist):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ///Gather and register the node ports. public void GatherPorts() { inputPorts = new Dictionary<string, Port>(StringComparer.Ordinal); outputPorts = new Dictionary<string, Port>(StringComparer.Ordinal); try { RegisterPorts(); } finally { DeserializeInputPortValues(); #if UNITY_EDITOR && DO_EDITOR_BINDING OnPortsGatheredInEditor(); ValidateConnections(); #endif } } |
I don’t really like this solution a lot though. Let me know what you think.
Thanks.
Thank you for your reply.
The solution resolve in part the problem. When the exception is not verified the data of valueinput are restore correctly but the connections are lost.
This video reproduce of issue:
Hello again,
This is the only way to handle this correctly (even though it’s ugly):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ///Gather and register the node ports. public void GatherPorts() { inputPorts = new Dictionary<string, Port>(StringComparer.Ordinal); outputPorts = new Dictionary<string, Port>(StringComparer.Ordinal); try { RegisterPorts(); #if UNITY_EDITOR && DO_EDITOR_BINDING ValidateConnections(); #endif } finally { DeserializeInputPortValues(); #if UNITY_EDITOR && DO_EDITOR_BINDING OnPortsGatheredInEditor(); #endif } } |
Let me know what you think.
Thanks.