From c9bb222bff700e80f61708cef883acd5e1153924 Mon Sep 17 00:00:00 2001 From: Dylan Jeannin Date: Mon, 20 Jul 2026 13:47:19 +0200 Subject: [PATCH] WeatherParameters: Debug crash pamhyr when select a reach without geometry --- .../WeatherParameters/WeatherParameters.py | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Model/WeatherParameters/WeatherParameters.py b/src/Model/WeatherParameters/WeatherParameters.py index edcab64b..881ab35f 100644 --- a/src/Model/WeatherParameters/WeatherParameters.py +++ b/src/Model/WeatherParameters/WeatherParameters.py @@ -397,24 +397,21 @@ class WeatherParameters(SQLSubModel): wp._begin_section = None wp._end_section = None - if row[3] != -1: + if reach not in (-1, None): wp.reach = next( - filter( - lambda e: e.id == reach, - edges - ) + (edge for edge in edges if edge.id == reach), None + ) + profiles = ( + wp.reach.reach.profiles + if wp.reach is not None else [] ) wp._begin_section = next( - filter( - lambda p: p.id == b_section, - wp.reach.reach.profiles - ) + (profile for profile in profiles + if profile.id == b_section), None ) wp._end_section = next( - filter( - lambda p: p.id == e_section, - wp.reach.reach.profiles - ) + (profile for profile in profiles + if profile.id == e_section), None ) data["wp"] = wp @@ -537,9 +534,14 @@ class WeatherParameters(SQLSubModel): @reach.setter def reach(self, reach): self._reach = reach + self._begin_section = None + self._end_section = None + if reach is not None: - self._begin_section = self._reach.reach.profiles[0] - self._end_section = self._reach.reach.profiles[-1] + profiles = reach.reach.profiles + if profiles: + self._begin_section = profiles[0] + self._end_section = profiles[-1] self.modified()