nem0 / LumixEngine

3D C++ Game Engine - yet another open source game engine
MIT License
3.46k stars 392 forks source link

Really tiny semi-issue regarding imgui docking implementation (enhancement I guess) #795

Closed JWki closed 8 years ago

JWki commented 8 years ago

This is a really really small thing and I don't think it would ever be an issue in Lumix but I've spent enough time on it that I thought I'd point it out - in the imgui_dock implementation, ShutdownDock() frees the memory of each individual block of data referenced by the m_docks array in the global DockContext instance, however it does not free the memory of the array itself. That's usually not an issue as the memory is freed when the global instance is destructed, however as the destruction order of static variables in C++ is implementation dependent and quasi random, it can become an issue in very specific situations. It was an issue for me when integrating the docking solution into my own GUI code as I use a custom allocator for ImGui allocations that asserts on destruction when any allocations served by the allocator have not been freed. This allocator happened to be static variable which was destructed before the global DockContext instance, leading to the assertion. I'm aware that this may not be especially relevant to Lumix, but I can imagine that there's a possibility it may somehow become relevant. I have deliberately marked this as an enhancement rather than a bug as it doesn't seem to be an issue in Lumix at the moment, but in my eyes it does enhance the docking implementation even if it is just a little.

nem0 commented 8 years ago

I do not have my custom allocator used in imgui so it's just a blind fix. Hope it works.