Compare commits
3 Commits
a3b3a9b6e8
...
1d4087e842
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d4087e842 | |||
| daebf5eaa0 | |||
| d068bcbabd |
@@ -39,7 +39,15 @@ namespace Archimedes {
|
||||
|
||||
virtual void run() = 0;
|
||||
|
||||
virtual void stopModule(std::string lib) { toClose.push_back(lib); }
|
||||
virtual void stopModule(std::string lib) {
|
||||
//unload modules that depend on the one we are unloading
|
||||
for(std::string s : runOrder) {
|
||||
if(modules[s]->deps.find(lib) != modules[s]->deps.end()) {
|
||||
stopModule(s);
|
||||
}
|
||||
}
|
||||
toClose.push_back(lib);
|
||||
}
|
||||
|
||||
virtual void startModule(std::variant<std::string, Module*> m) { toOpen.push_back(m); }
|
||||
|
||||
@@ -148,27 +156,42 @@ namespace Archimedes {
|
||||
|
||||
virtual void unload(std::string name) {
|
||||
|
||||
std::cout << "Attempting to unload module: " << name << std::endl;
|
||||
|
||||
if(modules.find(name) == modules.end())
|
||||
return;
|
||||
|
||||
/*
|
||||
//unload modules that depend on the one we are unloading
|
||||
for(std::string s : runOrder) {
|
||||
if(modules[s]->deps.find(name) != modules[s]->deps.end()) {
|
||||
unload(s);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
Module* m = modules[name];
|
||||
void* h = m->getHandle();
|
||||
|
||||
modules[name] = nullptr;
|
||||
|
||||
runOrder.remove(name);
|
||||
|
||||
if(h) {
|
||||
delete m;
|
||||
dlclose(h);
|
||||
//don't dlclose if other modules are still in runOrder!
|
||||
bool closable = true;
|
||||
for(auto s = runOrder.begin(); s != runOrder.end(); s++) {
|
||||
if(modules[*s]->getHandle() == h) {
|
||||
closable = false;
|
||||
}
|
||||
}
|
||||
|
||||
runOrder.remove(name);
|
||||
delete m;
|
||||
|
||||
if(closable) {
|
||||
dlclose(h);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Successfully unloaded module: " << name << std::endl;
|
||||
}
|
||||
|
||||
virtual void printHelp() = 0;
|
||||
|
||||
@@ -11,12 +11,15 @@ ImguiModule::ImguiModule(Archimedes::App* a, void* h = nullptr) : Archimedes::Mo
|
||||
|
||||
name = "ImguiModule";
|
||||
|
||||
WindowModule* wm = new WindowModule(a);
|
||||
WindowModule* wm = new WindowModule(a, h);
|
||||
deps[wm->getName()] = wm;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -23,6 +23,8 @@ class ImguiModule : public Archimedes::Module {
|
||||
private:
|
||||
|
||||
ImGuiContext* context;
|
||||
|
||||
std::list<std::function<void()>>::iterator rcmd_it;
|
||||
};
|
||||
|
||||
#ifdef IMGUIMODULE_DYNAMIC
|
||||
|
||||
@@ -6,7 +6,7 @@ MainGUI::MainGUI(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
|
||||
|
||||
name = "MainGUI";
|
||||
|
||||
ImguiModule* im = new ImguiModule(a, nullptr);
|
||||
ImguiModule* im = new ImguiModule(a, h);
|
||||
deps[im->getName()] = im;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ Ollama::Ollama(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
|
||||
|
||||
name = "Ollama";
|
||||
|
||||
ImguiModule* im = new ImguiModule(a, nullptr);
|
||||
ImguiModule* im = new ImguiModule(a, h);
|
||||
deps[im->getName()] = im;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ Terminal::Terminal(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
|
||||
|
||||
name = "Terminal";
|
||||
|
||||
ImguiModule* im = new ImguiModule(a, nullptr);
|
||||
ImguiModule* im = new ImguiModule(a, h);
|
||||
deps[im->getName()] = im;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
|
||||
|
||||
name = "TestImgui";
|
||||
|
||||
ImguiModule* im = new ImguiModule(a, nullptr);
|
||||
ImguiModule* im = new ImguiModule(a, h);
|
||||
deps[im->getName()] = im;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user