ImNodesContext Initialization error
david-rokeby opened this issue · 1 comments
I am making an app with multiple node editor windows. I am creating a new ImNodeContext (and editor context) for each new window.
I was able to get everything working except that the last editor always had transparent ImNode features, with the ImGui widgets normal, but no Node box.
The problem turned out to be in the ImNodesContext Initialization routine.
void Initialize(ImNodesContext* context) calls StyleColorsDark() which sets GImNodes's Style, rather than the style of the context being initialized. If I call ImNodes::SetCurrentContext(nullptr) before creating a new context, then everything works... GImNodes only gets set to the new context if it was set to nullptr when Initialize is called.
ImNodesContext* CreateContext()
{
ImNodesContext* ctx = IM_NEW(ImNodesContext)();
if (GImNodes == NULL)
SetCurrentContext(ctx);
Initialize(ctx);
return ctx;
}
Hi @david-rokeby and thanks for reporting the issue! That's definitely a problem which needs to be fixed.
This issue uncovered another bug with the context initialization as well as an API design issue. I'll try to get the bugs fixed as soon as possible and revisit the API design later on.