Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
1.97k stars 241 forks source link

LoadEditorStateFromIni*() functions depend on the global context #108

Open TetraSomia opened 3 years ago

TetraSomia commented 3 years ago

Hello,

First thanks for your cool ImGui extension !

I was playing with multiple contexts and realized that the functions loading a custom context (LoadEditorStateFromIniFile() and LoadEditorStateFromIniString()) were also using the global context in ObjectPoolFindOrCreateIndex<ImNodeData>() when called from NodeLineHandler():

https://github.com/Nelarius/imnodes/blob/61c609a2ed5a4404b45137d21d9e7e48d125ee53/imnodes_internal.h#L466

So I'm currently calling SetImGuiContext() before loading the context but it might be great to make those function completely agnostic of the global context when we provide a custom context as parameter :)

Also in certain conditions, an uninitialized value occurs on StartPinIdx when creating an ImClickInteractionState:

https://github.com/Nelarius/imnodes/blob/61c609a2ed5a4404b45137d21d9e7e48d125ee53/imnodes_internal.h#L211

I didn't create another issue for this as I can't replicate this easily ATM and give additional info about it, sorry :s You may want to run valgrind on your examples to see if it appears on them. If not, tell me and I'll try to find back my faulty example.

Thanks !