mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 06:35:21 +01:00
fix: the five bugs SonarQube Cloud reports on staging (reliability E)
- application/driveruipanels.cpp (S3584, blocker): the UART section of the debug panel leaked a new char*[] of the port names every frame it was open; the names go through a vector now. - rendering/vulkan14/vulkan14swapchain.cpp (S1048): the destructor called destroy(), whose release_images() keeps the presentation semaphores in a vector and may throw on allocation; the destructor catches it. - rendering/vulkan14/vulkan14scene.cpp (S2259): walk_shadow_material() dereferenced m_context, which own_shadow_program() just before treats as possibly empty; it returns without a context. - tests/unit/test_door_component.cpp, test_consist_braking.cpp (S2193): the float loop counters become while loops summing the same time, so the cases take exactly the steps they took before.
This commit is contained in:
@@ -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<int>(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<char const *> 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<int>(avlports.size()));
|
||||
ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, static_cast<int>(uart_baudrates_list_num));
|
||||
ImGui::Checkbox("Enabled", &UartStatus.enabled);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user