Closed Thalhammer closed 2 years ago
Found out you're supposed to use CreateEditorContext for this use case, however I still think that given the functions for multiple contexts exists it should work correctly.
Hi @Thalhammer ! Glad you were able to figure it out.
You raised an interesting issue. There's two kinds of state behind the scenes:
ImNodesContext
. It also contains a pointer to the current ImNodesEditorContext
.ImNodesEditorContext
.I suppose there is no reason why we couldn't just have a single ImNodesContext
which would contain everything we need. It might be easier for someone who is trying to use the library solely based on reading imnodes.h
.
I will keep this open issue open, as this is something to consider before making the API final.
Describe the bug Maybe I am not using it correctly, but it looks like creating multiple contexts is broken. From what I found the reason for this is that
void Initialize(ImNodesContext* context)
setsGImNodes->EditorCtx
toGImNodes->DefaultEditorCtx
even if the newly created context is not the current global context. This is causing a crash once you attempt to use the newly created context, becausecontext->EditorCtx
is null. https://github.com/Nelarius/imnodes/blob/master/imnodes.cpp#L1633 The fix for this should be simple:context->EditorCtx = context->DefaultEditorCtx
How To Reproduce
Expected behavior
global
andctx
represent two distinct contexts, each of which can be used for rendering and does not influence each other or leak memory.Desktop: