imgui-node-editor icon indicating copy to clipboard operation
imgui-node-editor copied to clipboard

EditorContext pointers stored in objects breaks live reloading?

Open ddengster opened this issue 4 years ago • 1 comments

Hi, I run a live reloading setup where I hotload code in from a dll after compiling it. It crashes because I suspect objects are using EditorContext pointers are no longer valid after reloading. This is the reason why imgui has ImGui::SetCurrentContext, which I call in the start of my update loop. Likewise I call ImNodeEd::SetCurrentEditor in the same manner.

So likely the solution to this is to not store EditorContext* Editor pointers in your structs like EditorAction, AnimationController, etc and call the GetEditorContext() function to ensure an up-to-date address.

Also, here's another side problem: GetCurrentEditor() returns ax::NodeEditor::EditorContext*, while the struct EditorContext is under the ax::NodeEditor::Detail namespace.

ddengster avatar Feb 02 '20 07:02 ddengster

Lifetimes of EditorAction and AnimationController are tied to EditorContext. If it goes away, everything else is also going away. Also public API does not return internal pointers.

I do not yet see how node editor can break hotload. Can you give me more details?

It was my intention for ax::NodeEditor::EditorContext to be undefined so pointer to this structure can act as opaque handle. I think reinterpret_cast<> can be seen as UB here. To solve that I think I will join both structs. Thanks for pointing that out.

thedmd avatar Apr 14 '20 18:04 thedmd