Skip to content

Commit

Permalink
Ignore IndexOutOfRangeException when clearing nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed May 10, 2020
1 parent 6078b61 commit fcdb148
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/KerbalTools.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using KSP;

Expand Down Expand Up @@ -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*
}
}

Expand Down

0 comments on commit fcdb148

Please sign in to comment.