make ImguiModule safe to unload

This commit is contained in:
2025-04-12 18:19:16 -05:00
parent daebf5eaa0
commit 1d4087e842
3 changed files with 8 additions and 1 deletions

View File

@@ -191,7 +191,7 @@ namespace Archimedes {
}
}
std::cout << "Successfully unloaded module: " << name << std::endl << "runOrder.empty(): " << runOrder.empty() << std::endl;
std::cout << "Successfully unloaded module: " << name << std::endl;
}
virtual void printHelp() = 0;

View File

@@ -17,6 +17,9 @@ ImguiModule::ImguiModule(Archimedes::App* a, void* h = nullptr) : Archimedes::Mo
ImguiModule::~ImguiModule() {
WindowModule* wm = (WindowModule*) moduleInstances["WindowModule"];
wm->getRenderer()->getCmdList().erase(rcmd_it);
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
@@ -61,6 +64,8 @@ void ImguiModule::onLoad() {
ImGui::NewFrame();
});
rcmd_it = --wm->getRenderer()->getCmdList().end()++;
//Compute first frame ahead of first WindowModule->run()
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();

View File

@@ -23,6 +23,8 @@ class ImguiModule : public Archimedes::Module {
private:
ImGuiContext* context;
std::list<std::function<void()>>::iterator rcmd_it;
};
#ifdef IMGUIMODULE_DYNAMIC