Skip to content

Commit

Permalink
fixed stations dialog in gui crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
xLPMG committed Jan 31, 2024
1 parent 7b64839 commit c484118
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/ui/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,21 +1010,23 @@ int tsunami_lab::ui::GUI::launch()
}
}

ImGui::BeginListBox("Stations");
auto it = m_stations.begin();
while (it != m_stations.end())
if (ImGui::BeginListBox("Stations"))
{
std::string name = it->name + " (" + std::to_string(it->positionX) + ", " + std::to_string(it->positionY) + ")";
if (ImGui::Selectable(name.c_str(), it->isSelected))
auto it = m_stations.begin();
while (it != m_stations.end())
{
it = m_stations.erase(it);
}
else
{
it++;
std::string name = it->name + " (" + std::to_string(it->positionX) + ", " + std::to_string(it->positionY) + ")";
if (ImGui::Selectable(name.c_str(), it->isSelected))
{
it = m_stations.erase(it);
}
else
{
it++;
}
}
ImGui::EndListBox();
}
ImGui::EndListBox();
ImGui::SetItemTooltip("Click to remove");

ImGui::TreePop();
Expand All @@ -1035,7 +1037,7 @@ int tsunami_lab::ui::GUI::launch()
ImGui::Text("Current time step scaling: %f", m_timeStepScaling);
ImGui::SliderFloat("Scaling (0-1)", &m_timeStepScaling, 0.1f, 1.0f, "%.2f");
ImGui::SameLine();
HelpMarker("The default value is 1. Smaller numbers lead to more timesteps and thus to a more detailed simulation. However this also increases the computation time.");
HelpMarker("The default value is 1. Smaller numbers lead to more timesteps and thus to a more detailed simulation. However this also increases the computation time.");
ImGui::TreePop();
}

Expand Down

0 comments on commit c484118

Please sign in to comment.