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.
This commit is contained in:
2026-02-14 14:32:32 +01:00
parent a2befb3ff9
commit 1a88e5fc40
+3 -7
View File
@@ -118,23 +118,19 @@ void Simulators::switch_simulator(std::string name)
SPDLOG_WARN("no simulators found"); SPDLOG_WARN("no simulators found");
return; 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()) if (this->m_simulators.find(name) == this->m_simulators.end())
{ {
SPDLOG_WARN("simulator {} not found", name); SPDLOG_WARN("simulator {} not found", name);
return; return;
} }
this->stop();
if (!this->m_current_simulator.empty()) 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()); disconnect(m_simulators.at(m_current_simulator).get());
} }
this->m_current_simulator = name; this->m_current_simulator = name;
connect(m_simulators.at(m_current_simulator).get(), &Simulator_base::sim_changed, this, connect(m_simulators.at(m_current_simulator).get(), &Simulator_base::sim_changed, this,
[this] { [this] {