ui/map_eta: avoid divide by zero (#31962)

pull/32233/head
Dean Lee 1 year ago committed by GitHub
parent db5eb58d91
commit 2bee28938a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      selfdrive/ui/qt/maps/map_eta.cc

@ -38,10 +38,13 @@ void MapETA::updateETA(float s, float s_typical, float d) {
auto remaining = s < 3600 ? std::pair{QString::number(int(s / 60)), tr("min")}
: std::pair{QString("%1:%2").arg((int)s / 3600).arg(((int)s % 3600) / 60, 2, 10, QLatin1Char('0')), tr("hr")};
QString color = "#25DA6E";
if (s / s_typical > 1.5)
color = "#DA3025";
else if (s / s_typical > 1.2)
color = "#DAA725";
if (std::abs(s_typical) > 1e-5) {
if (s / s_typical > 1.5) {
color = "#DA3025";
} else if (s / s_typical > 1.2) {
color = "#DAA725";
}
}
// Distance
auto distance = map_format_distance(d, uiState()->scene.is_metric);

Loading…
Cancel
Save