I hate segfaults
This commit is contained in:
28
src/App.cpp
28
src/App.cpp
@@ -41,7 +41,11 @@ void App::run() {
|
||||
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||
(*it)->run();
|
||||
}
|
||||
closeModules();
|
||||
|
||||
for(auto it = toClose.begin(); it != modules.end(); it++) {
|
||||
unload(it);
|
||||
}
|
||||
toClose.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,23 +81,17 @@ void App::load(std::string lib) {
|
||||
}
|
||||
|
||||
void App::unload(decltype(Module::self) it) {
|
||||
toClose.push_back((*it)->getHandle());
|
||||
std::cout << "marked handle for closure\n";
|
||||
std::cout << "Attempting to delete module: " << (*it)->getName() << std::endl;
|
||||
Module* m = *it;
|
||||
*it = nullptr;
|
||||
modules.erase(it);
|
||||
std::cout << "erased iterator\n";
|
||||
delete m;
|
||||
void* h = (*it)->getHandle();
|
||||
std::cout << "retrieved handle\nAttempting to delete module: " << (*it)->getName() << std::endl;
|
||||
delete *it;
|
||||
std::cout << "deleted module\n";
|
||||
|
||||
dlclose(h);
|
||||
std::cout << "closed handle\n";
|
||||
}
|
||||
|
||||
void App::closeModules() {
|
||||
for(auto h : toClose) {
|
||||
dlclose(h);
|
||||
}
|
||||
toClose.clear();
|
||||
void App::stopModule(decltype(Module::self) it) {
|
||||
toClose.push_back(*it);
|
||||
modules.erase(it);
|
||||
}
|
||||
|
||||
void App::handleArgs(const int& argc, char* argv[]) {
|
||||
|
||||
Reference in New Issue
Block a user