diff --git a/applications/gui2/src/views/addsource.cpp b/applications/gui2/src/views/addsource.cpp index a1115d743f14b8160e0e46d02e71eefd63b928e9..926cd8340282704f8a1d7e090b4910a6f397407a 100644 --- a/applications/gui2/src/views/addsource.cpp +++ b/applications/gui2/src/views/addsource.cpp @@ -27,7 +27,9 @@ AddSourceWindow::AddSourceWindow(nanogui::Widget* parent, AddCtrl *ctrl) : rebuild(); new_source_handle_ = ctrl_->feed()->onNewSources([this](int a) { - while(childCount() > 0) { removeChild(childCount()-1); } + UNIQUE_LOCK(mutex_, lk); + // Note the 1, first widget is the title bar buttons + while(childCount() > 1) { removeChild(childCount()-1); } rebuild(); screen()->performLayout(); return true; diff --git a/applications/gui2/src/views/addsource.hpp b/applications/gui2/src/views/addsource.hpp index 44dcd00c5e465a6e94092f42471f6b7301670a6c..fcca02ecca0c260ddf1fd94f64551b30320ab481 100644 --- a/applications/gui2/src/views/addsource.hpp +++ b/applications/gui2/src/views/addsource.hpp @@ -2,6 +2,7 @@ #include <nanogui/window.h> #include <ftl/handle.hpp> +#include <ftl/threads.hpp> namespace ftl { @@ -25,6 +26,7 @@ private: void rebuild(); ftl::Handle new_source_handle_; + MUTEX mutex_; public: // EIGEN_MAKE_ALIGNED_OPERATOR_NEW diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index aba5beede2a9fd37c56c977f49acf794f6442b0b..cdd483ec03be502d662765f6a88d054145b7b9cc 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -242,6 +242,7 @@ static std::map<std::string, ftl::Configurable*> config_instance; static std::map<std::string, ftl::Configurable*> config_alias; static std::map<std::string, std::vector<ftl::Configurable*>> tag_index; +static std::string cfg_root_str; static nlohmann::json config_restore; static nlohmann::json config_defaults; @@ -667,7 +668,7 @@ void ftl::config::cleanup() { } config_instance.clear(); - ftl::saveJSON(FTL_LOCAL_CONFIG_ROOT "/session.json", config_restore); + ftl::saveJSON(std::string(FTL_LOCAL_CONFIG_ROOT "/")+cfg_root_str+std::string("_session.json"), config_restore); doing_cleanup = false; } @@ -839,11 +840,12 @@ Configurable *ftl::config::configure(int argc, char **argv, const std::string &r } string root_str = (options.find("root") != options.end()) ? nlohmann::json::parse(options["root"]).get<string>() : root; + cfg_root_str = root_str; if (options.find("id") != options.end()) config["$id"] = nlohmann::json::parse(options["id"]).get<string>(); _indexConfig(config); - config_restore = std::move(ftl::loadJSON(FTL_LOCAL_CONFIG_ROOT "/session.json")); + config_restore = std::move(ftl::loadJSON(std::string(FTL_LOCAL_CONFIG_ROOT "/")+cfg_root_str+std::string("_session.json"))); Configurable *rootcfg = create<Configurable>(config); if (root_str.size() > 0) {