Skip to content
Snippets Groups Projects
Commit 0ec347f3 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Improve feed cleanup

parent 49967afc
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
......@@ -147,24 +147,26 @@ int main(int argc, char **argv) {
nanogui::init();
FTLGui gui(argc, argv);
{
FTLGui gui(argc, argv);
try {
gui.mainloop();
}
catch (const ftl::exception &e) {
try {
gui.mainloop();
}
catch (const ftl::exception &e) {
LOG(ERROR) << "Fatal error: " << e.what();
LOG(ERROR) << e.trace();
}
catch (const std::runtime_error &e) {
std::string error_msg = std::string("Caught a fatal error: ") + std::string(e.what());
#ifdef _WIN32
MessageBoxA(nullptr, error_msg.c_str(), NULL, MB_ICONERROR | MB_OK);
#else
LOG(ERROR) << error_msg;
#endif
return -1;
LOG(ERROR) << "Fatal error: " << e.what();
LOG(ERROR) << e.trace();
}
catch (const std::runtime_error &e) {
std::string error_msg = std::string("Caught a fatal error: ") + std::string(e.what());
#ifdef _WIN32
MessageBoxA(nullptr, error_msg.c_str(), NULL, MB_ICONERROR | MB_OK);
#else
LOG(ERROR) << error_msg;
#endif
return -1;
}
}
nanogui::shutdown();
......
......@@ -662,9 +662,13 @@ void ftl::config::cleanup() {
//UNIQUE_LOCK(mutex, lk);
for (auto f : config_instance) {
for (auto &f : config_instance) {
LOG(WARNING) << "Not deleted properly: " << f.second->getID();
//delete f.second;
f.second->save();
// f.second->save();
}
while (config_instance.begin() != config_instance.end()) {
delete config_instance.begin()->second;
}
config_instance.clear();
......@@ -674,7 +678,7 @@ void ftl::config::cleanup() {
}
void ftl::config::removeConfigurable(Configurable *cfg) {
if (doing_cleanup) return;
//if (doing_cleanup) return;
UNIQUE_LOCK(mutex, lk);
auto i = config_instance.find(cfg->getID());
......
......@@ -54,9 +54,10 @@ class Source : public ftl::Configurable, public ftl::data::DiscreteSource {
protected:
explicit Source(ftl::config::json_t &cfg);
Source(ftl::config::json_t &cfg, ftl::net::Universe *net);
virtual ~Source();
public:
virtual ~Source();
/**
* Is this source valid and ready to grab?.
*/
......
......@@ -86,6 +86,7 @@ private:
std::map<uint32_t, ftl::data::FrameSetPtr> latest_;
std::unordered_map<uint32_t, ftl::stream::Stream*> streams_;
std::unordered_map<uint32_t, ftl::rgbd::Source*> devices_;
std::unordered_map<uint32_t, ftl::operators::Graph*> pre_pipelines_;
std::vector<std::string> netcams_;
......
......@@ -194,9 +194,16 @@ Feed::~Feed() {
delete filter;
}
filters_.clear();
// TODO stop everything and clean up
// delete pre_pipelines_
// delete
for (auto &p : pre_pipelines_) {
delete p.second;
}
for (auto &d : devices_) {
delete d.second;
}
}
......@@ -509,8 +516,10 @@ uint32_t Feed::add(const std::string &path) {
// to the texture objects for use by Camera.
source = ftl::create<ftl::render::Source>(this, srcname, this);
} else {
source = ftl::create<ftl::rgbd::Source>(this, srcname, net_);
auto *dsource = ftl::create<ftl::rgbd::Source>(this, srcname, net_);
_createPipeline(fsid);
devices_[fsid] = dsource;
source = dsource;
}
// Create local builder instance
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment