diff --git a/src/process.cpp b/src/process.cpp index fdf92398..892a1ff1 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -172,11 +172,11 @@ namespace proc { int proc_t::execute(const ctx_t& app, std::shared_ptr launch_session) { if (_app_id == input_only_app_id) { - terminate(); + terminate(false, false); std::this_thread::sleep_for(1s); } else { // Ensure starting from a clean slate - terminate(); + terminate(false, false); } _app = app; @@ -572,7 +572,7 @@ namespace proc { return 0; } - void proc_t::terminate(bool immediate) { + void proc_t::terminate(bool immediate, bool needs_refresh) { std::error_code ec; placebo = false; @@ -671,13 +671,9 @@ namespace proc { virtual_display = false; allow_client_commands = false; - if (refreshing) { - return; + if (needs_refresh) { + refresh(config::stream.file_apps, false); } - - refreshing = true; - refresh(config::stream.file_apps); - refreshing = false; } const std::vector &proc_t::get_apps() const { @@ -1393,11 +1389,9 @@ namespace proc { }; } - void refresh(const std::string &file_name) { - if (!proc.refreshing) { - proc.refreshing = true; - proc.terminate(); - proc.refreshing = false; + void refresh(const std::string &file_name, bool needs_terminate) { + if (needs_terminate) { + proc.terminate(false, false); } #ifdef _WIN32 diff --git a/src/process.h b/src/process.h index a2fb5709..ba3e3937 100644 --- a/src/process.h +++ b/src/process.h @@ -100,8 +100,6 @@ namespace proc { bool initial_hdr; bool virtual_display; bool allow_client_commands; - bool refreshing; - proc_t( boost::process::v1::environment &&env, @@ -129,7 +127,7 @@ namespace proc { std::string get_last_run_app_name(); std::string get_running_app_uuid(); boost::process::environment get_env(); - void terminate(bool immediate = false); + void terminate(bool immediate = false, bool needs_refresh = true); private: int _app_id; @@ -164,7 +162,7 @@ namespace proc { std::tuple calculate_app_id(const std::string &app_name, std::string app_image_path, int index); std::string validate_app_image_path(std::string app_image_path); - void refresh(const std::string &file_name); + void refresh(const std::string &file_name, bool needs_terminate = true); void migrate_apps(nlohmann::json* fileTree_p, nlohmann::json* inputTree_p); std::optional parse(const std::string &file_name);