From fcdb148e00dde5d6b97f6482eeed2b293a1eb150 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sun, 10 May 2020 21:16:51 +0000 Subject: [PATCH] Ignore IndexOutOfRangeException when clearing nodes --- src/KerbalTools.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/KerbalTools.cs b/src/KerbalTools.cs index 6e35221..90114b5 100644 --- a/src/KerbalTools.cs +++ b/src/KerbalTools.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using KSP; @@ -286,8 +287,16 @@ public static Orbit NextPatch(Orbit currentPatch) public static void ClearManeuverNodes() { PatchedConicSolver solver = FlightGlobals.ActiveVessel.patchedConicSolver; - while (solver.maneuverNodes.Count > 0) { - solver.maneuverNodes.First().RemoveSelf(); + try + { + while (solver.maneuverNodes.Count > 0) { + solver.maneuverNodes.First().RemoveSelf(); + } + } + catch (IndexOutOfRangeException) + { + // This can be thrown if another thread clears it before us. + // *Shrug* } }