diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 716b7db63c1f4e..586bd813493d35 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -228,8 +228,8 @@ def update(self, cp, cp_cam, CC, frogpilot_toggles): fp_ret.ecoGear = cp.vl["GEAR_PACKET"]['ECON_ON'] == 1 fp_ret.sportGear = cp.vl["GEAR_PACKET"]['SPORT_ON_2' if self.CP.flags & ToyotaFlags.NO_DSU else 'SPORT_ON'] == 1 + self.lkas_previously_enabled = self.lkas_enabled if self.CP.carFingerprint != CAR.TOYOTA_PRIUS_V: - self.lkas_previously_enabled = self.lkas_enabled self.lkas_enabled = self.lkas_hud.get("LDA_ON_MESSAGE") == 1 # ZSS Support - Credit goes to Erich! diff --git a/selfdrive/frogpilot/assets/theme_manager.py b/selfdrive/frogpilot/assets/theme_manager.py index c7f8a1d2d1f5d9..48b78826d4b48d 100644 --- a/selfdrive/frogpilot/assets/theme_manager.py +++ b/selfdrive/frogpilot/assets/theme_manager.py @@ -401,6 +401,7 @@ def validate_themes(self, frogpilot_toggles): "WheelIcon": ("steering_wheels", frogpilot_toggles.wheel_image) } + theme_downloaded = False for theme_param, (theme_component, theme_name) in asset_mappings.items(): if theme_name in {"none", "stock"}: continue @@ -418,9 +419,13 @@ def validate_themes(self, frogpilot_toggles): else: theme_path = os.path.join(THEME_SAVE_PATH, "theme_packs", theme_name, theme_component) - if theme_path and not os.path.exists(theme_path): + if theme_path is None or not os.path.exists(theme_path): print(f"{theme_name} for {theme_component} not found. Downloading...") self.download_theme(theme_component, theme_name, theme_param) + theme_downloaded = True + + if theme_downloaded: + update_frogpilot_toggles() def update_themes(self, frogpilot_toggles, boot_run=False): repo_url = get_repository_url() diff --git a/selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.cc b/selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.cc index 2ffd8c29bcd3f3..ca7aab4277a2c0 100644 --- a/selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.cc +++ b/selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.cc @@ -16,11 +16,15 @@ QColor loadThemeColors(const QString &colorKey, bool clearCache) { cachedColorData = QJsonObject(); QFile file("../frogpilot/assets/active_theme/colors/colors.json"); - while (!file.exists()) { + static int check_count = 0; + while (!file.exists() && check_count < 100) { + check_count += 1; util::sleep_for(100); } - file.open(QIODevice::ReadOnly); + if (!file.open(QIODevice::ReadOnly)) { + return QColor(); + } QByteArray fileData = file.readAll(); QJsonDocument doc = QJsonDocument::fromJson(fileData); @@ -28,6 +32,10 @@ QColor loadThemeColors(const QString &colorKey, bool clearCache) { cachedColorData = doc.object(); } + if (cachedColorData.isEmpty()) { + return QColor(); + } + QJsonObject colorObj = cachedColorData.value(colorKey).toObject(); return QColor( colorObj.value("red").toInt(0), diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index a6f67a9a86a274..e36122df9b8990 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -466,7 +466,7 @@ void ui_update_theme(UIState *s) { scene.use_stock_wheel = scene.frogpilot_toggles.value("wheel_image").toString() == "stock" && scene.frogpilot_toggles.value("current_holiday_theme").toString() == "stock"; if (!scene.use_stock_colors) { - loadThemeColors("", true); + scene.use_stock_colors |= !loadThemeColors("", true).isValid(); scene.lane_lines_color = loadThemeColors("LaneLines"); scene.lead_marker_color = loadThemeColors("LeadMarker");