I have created a custom drawing tool and during the creation of the object, I pass in certain object references that are then then subsequently released (i.e., set to null) when the drawing tool terminates (State == State.Terminated) for memory management purposes.
During the normal drawing tool lifecycle, this works fine, including on NinjaScript reload, etc.
However, if I open the Drawing Objects window, for example to edit another drawing tool such as a Rectangle that I may have manually drawn on the chart, and then click "OK" to commit the changes, then I wind up with a NullReferenceException because the final state of my custom drawing tool following that operation is "Terminated", as opposed to when it is created normally, where the final state is "Active".
So, in essence what happens is that opening the Drawing Objects window and committing the changes leaves the drawing tool in a Terminated, rather than an Active state on the chart, which means that the required references I passed in have been set to null with then subsequently breaks my handling of move interaction, Render, etc. since I now have on the chart what is ultimately a Terminated, and therefore invalid drawing object.
I walked through the situation in the debugger to see if there was anything in the state of the drawing tool I could use to avoid or work around this situation, and it doesn't appear that there is anything consistent. Right now, it seems that my only option is to not release the object reference or unsubscribe the event handlers, which I am not very fond of doing.
Any thoughts?
Comment