From 790a64af907331ee4ae9ae6fea388e4bba3bf5b0 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Mon, 6 Dec 2021 13:50:42 +0100 Subject: [PATCH] nav: open map on new route without valid OpenGL context (#23140) --- selfdrive/ui/qt/maps/map.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 7bee7f7ca5..e1bfe96c8e 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -112,10 +112,6 @@ void MapWindow::timerUpdate() { update(); - if (m_map.isNull()) { - return; - } - sm->update(0); if (sm->updated("liveLocationKalman")) { auto location = (*sm)["liveLocationKalman"].getLiveLocationKalman(); @@ -134,6 +130,21 @@ void MapWindow::timerUpdate() { velocity_filter.update(velocity); } } + + if (sm->updated("navRoute")) { + qWarning() << "Got new navRoute from navd. Opening map:" << allow_open; + + // Only open the map on setting destination the first time + if (allow_open) { + setVisible(true); // Show map on destination set/change + allow_open = false; + } + } + + if (m_map.isNull()) { + return; + } + loaded_once = loaded_once || m_map->isFullyLoaded(); if (!loaded_once) { map_instructions->showError("Map Loading"); @@ -186,7 +197,7 @@ void MapWindow::timerUpdate() { } if (sm->rcv_frame("navRoute") != route_rcv_frame) { - qWarning() << "Got new navRoute from navd"; + qWarning() << "Updating navLayer with new route"; auto route = (*sm)["navRoute"].getNavRoute(); auto route_points = capnp_coordinate_list_to_collection(route.getCoordinates()); QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {}); @@ -196,11 +207,6 @@ void MapWindow::timerUpdate() { m_map->updateSource("navSource", navSource); m_map->setLayoutProperty("navLayer", "visibility", "visible"); - // Only open the map on setting destination the first time - if (allow_open) { - setVisible(true); // Show map on destination set/change - allow_open = false; - } route_rcv_frame = sm->rcv_frame("navRoute"); } }