From 3f0e49628bb0a8d825bc89256d386ee1c50291df Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Fri, 10 Jul 2020 15:57:49 +0300 Subject: [PATCH] Fixes to restore locations and gui refresh --- applications/gui2/src/views/addsource.cpp | 4 +++- applications/gui2/src/views/addsource.hpp | 2 ++ components/common/cpp/src/configuration.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/applications/gui2/src/views/addsource.cpp b/applications/gui2/src/views/addsource.cpp index a1115d743..926cd8340 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 44dcd00c5..fcca02ecc 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 aba5beede..cdd483ec0 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) { -- GitLab