RemoveWaypoint throws collection modified error

BDCarrillo shared this bug 18 months ago
Reported

Calling RemoveWaypoint on a MyBasicMissionAutopilot throws a System.InvalidOperationException since the collection is modified. The subject code is below- seems the raised event is altering the m_waypoints collection while it's still being iterated.


		public void RemoveWaypoint(IMyAutopilotWaypoint waypoint)
		{
			foreach (MyAutopilotWaypoint waypoint2 in m_waypoints)
			{
				if (waypoint == waypoint2)
				{
					MyMultiplayer.RaiseEvent(this, (MyBasicMissionAutopilot x) => x.RemoveWaypoints, new int[1] { m_waypoints.IndexOf(waypoint2) });
				}
			}
		}

Replies (1)

photo
1

Hello BDCarrillo,

Thank you for reaching our forum and letting us know about this issue.

We have added this issue into our internal system.

Kind Regards,

Keen Software House: QA Department

Leave a Comment
 
Attach a file
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!