fix issues with imgui backend/renderer cleanup#7278
Conversation
If the graphics system fails to fully init for some reason then it's possible for the imgui backend and/or renderer to not be initialized. Those subsystems *must* be initialized before being shut down so we need to check for that to avoid hitting assertions inside of imgui. Also add a safety check for making sure that an imgui context exists before attempting to initialize the backend/renderer. A simple assertion should work for this as it would take a coder messing something up in order to trip it.
|
This issue was discovered testing the vulkan pr, but it's unrelated to the vulkan code, and could just as easily mess up when using OpenGL in the right circumstances. |
Goober5000
left a comment
There was a problem hiding this comment.
Is initializing it and then immediately shutting it down better than simply skipping shutting it down if it's not initialized?
Same problem: it can't be initialized twice so you'd have to check that it's not initialized already before initializing. Ideally we'd only be using imgui when required, which as far as I know is only for the lab and extra settings screens. So it would be set up when you enter the state in question and torn down when you leave that state. Much better than always allocating resources to imgui when it's not needed a vast majority of execution time. It's on my todo list to tackle that as part of an overhaul of that settings ui, but it's not a small job and pretty low priority. |
|
Should this also be tagged for the point release? |
I don't believe that anyone has encountered it before and it should be fairly rare with just OpenGL. So I don't think it's needed for the point release, but it wouldn't hurt if it happened to be included. |
If the graphics system fails to fully init for some reason then it's possible for the imgui backend and/or renderer to not be initialized. Those subsystems *must* be initialized before being shut down so we need to check for that to avoid hitting assertions inside of imgui. Also add a safety check for making sure that an imgui context exists before attempting to initialize the backend/renderer. A simple assertion should work for this as it would take a coder messing something up in order to trip it.
If the graphics system fails to fully init for some reason then it's possible for the imgui backend and/or renderer to not be initialized. Those subsystems must be initialized before being shut down so we need to check for that to avoid hitting assertions inside of imgui.
Also add a safety check for making sure that an imgui context exists before attempting to initialize the backend/renderer. A simple assertion should work for this as it would take a coder messing something up in order to trip it.