From e76ef93a833396dba4e3478966f9b48894c08638 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Mon, 14 Feb 2022 13:55:30 +0100 Subject: [PATCH] ui: fix onroad transition with active nav (#23757) --- selfdrive/ui/qt/onroad.cc | 12 ++++++++---- selfdrive/ui/ui.cc | 4 +--- selfdrive/ui/ui.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index f7e2dc9bf..44dde8581 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -80,11 +80,15 @@ void OnroadWindow::offroadTransition(bool offroad) { if (!offroad) { if (map == nullptr && (uiState()->prime_type || !MAPBOX_TOKEN.isEmpty())) { MapWindow * m = new MapWindow(get_mapbox_settings()); - m->setFixedWidth(topWidget(this)->width() / 2); - m->offroadTransition(offroad); - QObject::connect(uiState(), &UIState::offroadTransition, m, &MapWindow::offroadTransition); - split->addWidget(m, 0, Qt::AlignRight); map = m; + + QObject::connect(uiState(), &UIState::offroadTransition, m, &MapWindow::offroadTransition); + + m->setFixedWidth(topWidget(this)->width() / 2); + split->addWidget(m, 0, Qt::AlignRight); + + // Make map visible after adding to split + m->offroadTransition(offroad); } } #endif diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 007dc36d0..bbdd6d4f3 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -208,7 +208,7 @@ void UIState::updateStatus() { } // Handle onroad/offroad transition - if (scene.started != started_prev) { + if (scene.started != started_prev || sm->frame == 1) { if (scene.started) { status = STATUS_DISENGAGED; scene.started_frame = sm->frame; @@ -217,8 +217,6 @@ void UIState::updateStatus() { } started_prev = scene.started; emit offroadTransition(!scene.started); - } else if (sm->frame == 1) { - emit offroadTransition(!scene.started); } } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index cd7ea446e..6847a7bc9 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -141,7 +141,7 @@ private slots: private: QTimer *timer; - bool started_prev = true; + bool started_prev = false; }; UIState *uiState();