mbgl has its own retries that never work, don't reinit multiple times at once

pull/32571/head
Shane Smiskol 1 year ago
parent 75d4106415
commit 4a9290ef9d
  1. 15
      selfdrive/ui/qt/maps/map.cc
  2. 1
      selfdrive/ui/qt/maps/map.h

@ -22,6 +22,12 @@ const float MAP_SCALE = 2;
MapWindow::MapWindow(const QMapLibre::Settings &settings) : m_settings(settings), velocity_filter(0, 10, 0.05, false) {
QObject::connect(uiState(), &UIState::uiUpdate, this, &MapWindow::updateState);
reinit_timer.setSingleShot(true);
QObject::connect(&reinit_timer, &QTimer::timeout, this, [=] {
m_settings.setApiKey(get_mapbox_token());
initializeGL();
});
map_overlay = new QWidget (this);
map_overlay->setAttribute(Qt::WA_TranslucentBackground, true);
QVBoxLayout *overlay_layout = new QVBoxLayout(map_overlay);
@ -256,10 +262,11 @@ void MapWindow::initializeGL() {
QObject::connect(m_map.data(), &QMapLibre::Map::mapLoadingFailed, [=](QMapLibre::Map::MapLoadingFailure err_code, const QString &reason) {
LOGE("Map loading failed with %d: '%s'\n", err_code, reason.toStdString().c_str());
// if time is wrong, re-create token and try connecting again in 5s
if (err_code == QMapLibre::Map::MapLoadingFailure::StyleLoadFailure && reason.contains("SSL handshake failed")) {
m_settings.setApiKey(get_mapbox_token());
QTimer::singleShot(5000, this, &MapWindow::initializeGL);
// time could be wrong, re-create token and try connecting again in 5s
if (err_code == QMapLibre::Map::MapLoadingFailure::StyleLoadFailure && !loaded_once) {
if (!reinit_timer.isActive()) {
reinit_timer.start(5000);
}
}
});

@ -51,6 +51,7 @@ private:
void setError(const QString &err_str);
bool loaded_once = false;
QTimer reinit_timer;
// Panning
QPointF m_lastPos;

Loading…
Cancel
Save