-
Notifications
You must be signed in to change notification settings - Fork 71
Description
@beekayer posted in #64
(please avoid posting unrelated questions in existing topics, thank you)
I do need one more piece of advice. My application is a Lua runtime environment. So all of the TestEngine mechanisms are managed by an object I bind to the Lua context. If there's a Lua script error, my application lets you fix the Lua error and reload without exiting the application (thus ImGui context is preserved). Note, the Lua scripts are not in charge of creating and destroying ImGui context, nor creating new frames and rendering them. I am not using 1:1 ImGui -> Lua bindings, basically only widget ImGui API is exposed to Lua. All of this has been working well for years.
I've been able to get TestEngine working well except for one situation. On a reload, I don't destroy the ImGui context and I don't destroy the ImGuiTestEngine either. What I'm trying to do is get the TestEngine to a state where the same tests can be registered again and the TestEngine can be started again. Sequence of actions I'm trying to accomplish:
User has Lua error, fixes Lua error and invokes reload:
- ImGuiTestEngine_Stop()
- ImGuiTestEngine_UnregisterTest() <-- go through and unregister all tests because they will be loaded again when the Lua script is run again.
- .. what I want to do here is ImGuiTestEngine_UnbindImGuiContext() because you can't call ImGuiTestEngine_Start() with the TestEngine still having a reference to the ImGuiContext, but can't because that's a private function.
- Run Lua script again which does:
- For each test registered in Lua script: IM_REGISTER_TEST(), ImGuiTestEngine_QueueTest()
- ImGuiTestEngine_Start() <-- fails assert: IM_ASSERT(engine->UiContextTarget == NULL);
I see that ImGuiTestEngine_DestroyContext() calls ImGuiTestEngine_UnbindImGuiContext() but that's for a complete shutdown. Like I said, I'm keeping the application alive (i.e. I'm not destroying the ImGui context) for a reload. Any advice?