diff --git a/applications/gui2/src/main.cpp b/applications/gui2/src/main.cpp index 500baaca32287a84f9080ea5984a5c446154750a..95cc561591d417dc46931a3362b125e54acb1523 100644 --- a/applications/gui2/src/main.cpp +++ b/applications/gui2/src/main.cpp @@ -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(); diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index cdd483ec03be502d662765f6a88d054145b7b9cc..db446490b7311ae72a4605f9f026f45872c22683 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -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()); diff --git a/components/rgbd-sources/include/ftl/rgbd/source.hpp b/components/rgbd-sources/include/ftl/rgbd/source.hpp index 044978fdc38cc31b93f42102dcb38bef8bbf04c2..323a687c2c6d21b9829c1531d2585d838eedddc5 100644 --- a/components/rgbd-sources/include/ftl/rgbd/source.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/source.hpp @@ -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?. */ diff --git a/components/streams/include/ftl/streams/feed.hpp b/components/streams/include/ftl/streams/feed.hpp index 2f6d12e0368b20aa15f9f58002645abceedbb7ac..c4f8efda50bec7846831732ea11012b279a6025b 100644 --- a/components/streams/include/ftl/streams/feed.hpp +++ b/components/streams/include/ftl/streams/feed.hpp @@ -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_; diff --git a/components/streams/src/feed.cpp b/components/streams/src/feed.cpp index 5be03ebfee7c189a9439e8c9f774dde733fb7e0b..7c770caa90b890805d4aaff94d1107203a62bd80 100644 --- a/components/streams/src/feed.cpp +++ b/components/streams/src/feed.cpp @@ -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