From 61fd54c4966a495f9dea6d3fdd1596e6add7de54 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Fri, 17 May 2024 16:41:05 +0200
Subject: [PATCH] Geometry, Results: Fix HS display whene not associated.

---
 src/View/Geometry/PlotKPZ.py | 5 ++++-
 src/View/Results/PlotKPC.py  | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/View/Geometry/PlotKPZ.py b/src/View/Geometry/PlotKPZ.py
index 1c80af12..651a6758 100644
--- a/src/View/Geometry/PlotKPZ.py
+++ b/src/View/Geometry/PlotKPZ.py
@@ -191,7 +191,10 @@ class PlotKPZ(PamhyrPlot):
     def draw_profiles_hs(self, reach):
         lhs = filter(
             lambda hs: hs._input_reach.reach is reach,
-            self._study.river.hydraulic_structures.lst
+            filter(
+                lambda hs: hs._input_reach is not None,
+                self._study.river.hydraulic_structures.lst
+            )
         )
 
         for hs in lhs:
diff --git a/src/View/Results/PlotKPC.py b/src/View/Results/PlotKPC.py
index 77e101dc..74c08059 100644
--- a/src/View/Results/PlotKPC.py
+++ b/src/View/Results/PlotKPC.py
@@ -109,7 +109,10 @@ class PlotKPC(PamhyrPlot):
     def draw_profiles_hs(self, reach):
         lhs = filter(
             lambda hs: hs._input_reach.reach is reach.geometry,
-            self.results.study.river.hydraulic_structures.lst
+            filter(
+                lambda hs: hs._input_reach is not None,
+                self.results.study.river.hydraulic_structures.lst
+            )
         )
 
         for hs in lhs:
-- 
GitLab