diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index ede3f887e..5747b8934 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -639,12 +639,13 @@ debug_panel::render() { render_section_developer(); // Developer tools #ifdef WITH_UART if(true == render_section( "UART", m_uartlines)) { - auto ports_num = static_cast(UartStatus.available_ports.size()); - auto avlports = new char*[ports_num]; - for (int i=0; i < ports_num; i++) { - avlports[i] = (char *) UartStatus.available_ports[i].c_str(); + // the names of the ports for the list, kept by the vector for the call only (they were leaked every frame) + std::vector avlports; + avlports.reserve(UartStatus.available_ports.size()); + for (auto const &port : UartStatus.available_ports) { + avlports.push_back(port.c_str()); } - ImGui::Combo("Port", &UartStatus.selected_port_index, avlports, ports_num); + ImGui::Combo("Port", &UartStatus.selected_port_index, avlports.data(), static_cast(avlports.size())); ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, static_cast(uart_baudrates_list_num)); ImGui::Checkbox("Enabled", &UartStatus.enabled); } diff --git a/rendering/vulkan14/vulkan14scene.cpp b/rendering/vulkan14/vulkan14scene.cpp index 0e221446a..58e79bbfd 100644 --- a/rendering/vulkan14/vulkan14scene.cpp +++ b/rendering/vulkan14/vulkan14scene.cpp @@ -1721,6 +1721,11 @@ void vulkan14_renderer::walk_shadow_material(material_handle const Material) m_indirectsubmodel = nullptr; return; } + if (false == bool(m_context)) + { + // no device yet (own_shadow_program() checks it too): nothing to bind + return; + } auto &draw{*m_draw}; auto &scene{m_context->scene}; if (own != nullptr) diff --git a/rendering/vulkan14/vulkan14swapchain.cpp b/rendering/vulkan14/vulkan14swapchain.cpp index 7ceb07941..a1dfeec4f 100644 --- a/rendering/vulkan14/vulkan14swapchain.cpp +++ b/rendering/vulkan14/vulkan14swapchain.cpp @@ -70,7 +70,16 @@ bool wanted_srgb() swapchain::~swapchain() { - destroy(); + // a destructor mustn't throw: destroy() keeps the semaphores of the presentation for later in a vector, which may allocate. + // the program is closing or the swapchain is being replaced, so the worst is a semaphore not destroyed + try + { + destroy(); + } + catch (...) + { + // nothing to do with it here + } } bool swapchain::create(instance const &Instance, device const &Device, GLFWwindow *Window, std::string const &Name, std::uint32_t const Frames, std::string &Reason) diff --git a/tests/unit/test_consist_braking.cpp b/tests/unit/test_consist_braking.cpp index 78859f9db..5cce11815 100644 --- a/tests/unit/test_consist_braking.cpp +++ b/tests/unit/test_consist_braking.cpp @@ -34,9 +34,13 @@ struct elf { // the steps of the game: the physics of the cars, then the blending from the head car double step(double Seconds, double Dt = 0.01) { auto amax{0.0}; - for (auto time{0.0}; time < Seconds; time += Dt) { + // steps of Dt while the time summed so far is short of Seconds, as the cases were written; the time isn't a loop counter + // (S2193) + auto time{0.0}; + while (time < Seconds) { unit.step(line, Dt); amax = blending.Update(cab(), cars, {}, Dt); + time += Dt; } return amax; } diff --git a/tests/unit/test_door_component.cpp b/tests/unit/test_door_component.cpp index 7840d9010..ca968b88d 100644 --- a/tests/unit/test_door_component.cpp +++ b/tests/unit/test_door_component.cpp @@ -19,8 +19,12 @@ physics::door_data cab_controlled_doors() { } void run(physics::door_data &Doors, physics::door_data::StepInputs const &Inputs, double Seconds) { - for (auto time{0.0}; time < Seconds; time += 0.05) { + // steps of 0.05 s while the time summed so far is short of Seconds (as the cases were written: the sum rounds below a whole + // number of steps, so it takes one more); the time isn't a loop counter (S2193) + auto time{0.0}; + while (time < Seconds) { Doors.Update(Inputs, 0.05); + time += 0.05; } }