ImguiEmbed
This commit is contained in:
@@ -21,19 +21,19 @@ namespace Archimedes {
|
||||
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||
void* handle = (*it)->getHandle();
|
||||
delete *it;
|
||||
dlclose(handle);
|
||||
if(handle)
|
||||
dlclose(handle);
|
||||
it = modules.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool App::load(std::string lib, std::list<std::string> blacklist = {}) {
|
||||
Module* App::dynamicLoad(std::string lib) {
|
||||
|
||||
void* h = dlopen(lib.c_str(), RTLD_NOW);
|
||||
|
||||
if(!h) {
|
||||
std::cout << "could not open lib at: \"" << lib.c_str() << "\"\nError: " << dlerror() << std::endl;
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Module::create_t* create = (Module::create_t*) dlsym(h, "create");
|
||||
@@ -41,15 +41,25 @@ namespace Archimedes {
|
||||
if(err) {
|
||||
std::cout << "error finding create function in file: " << lib << std::endl;
|
||||
std::cout << "dlerror(): " << err << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Module* m = create(h, App::Get());
|
||||
return create(h, Get());
|
||||
}
|
||||
|
||||
bool App::load(Module* m, std::list<std::string> blacklist = {}) {
|
||||
|
||||
if(!m) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void* h = m->getHandle();
|
||||
for(auto it = blacklist.begin(); it != blacklist.end(); it++) {
|
||||
if(*it == m->getName()) {
|
||||
std::cout << "Module \"" << *it << "\" is already loaded!\n";
|
||||
delete m;
|
||||
dlclose(h);
|
||||
if(h)
|
||||
dlclose(h);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -66,7 +76,7 @@ namespace Archimedes {
|
||||
skip = false;
|
||||
continue;
|
||||
} else {
|
||||
load(it->second, blacklist);
|
||||
load(dynamicLoad(it->second), blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +95,9 @@ namespace Archimedes {
|
||||
|
||||
modules.erase(m->self);
|
||||
delete m;
|
||||
|
||||
dlclose(h);
|
||||
|
||||
if(h)
|
||||
dlclose(h);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user