From 1a88e5fc40e838ddf3e80123a5c086a033ca8864 Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Mon, 20 Oct 2025 19:56:28 +0200 Subject: [PATCH] b server sim switching Rearranges the order of operations during simulator switching to ensure that the previous simulator is properly stopped and disconnected before the new simulator is started. --- server/simulators.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server/simulators.cpp b/server/simulators.cpp index e0ef15a..8f22101 100644 --- a/server/simulators.cpp +++ b/server/simulators.cpp @@ -118,23 +118,19 @@ void Simulators::switch_simulator(std::string name) SPDLOG_WARN("no simulators found"); return; } - if (!this->m_current_simulator.empty()) - { - SPDLOG_INFO("stopping current simulator {} and switching to {}", m_current_simulator, name); - this->m_simulators.at(m_current_simulator)->stop(); - } - if (this->m_simulators.find(name) == this->m_simulators.end()) { SPDLOG_WARN("simulator {} not found", name); return; } - this->stop(); if (!this->m_current_simulator.empty()) { + SPDLOG_INFO("stopping current simulator {} and switching to {}", m_current_simulator, name); + this->m_simulators.at(m_current_simulator)->stop(); disconnect(m_simulators.at(m_current_simulator).get()); } + this->m_current_simulator = name; connect(m_simulators.at(m_current_simulator).get(), &Simulator_base::sim_changed, this, [this] {