Remove sub-stage from removed component

Fixes a bug where if you delete the parent component of a booster set, it would throw a NullPointerException in BarrowmanCalculator.java:861
This commit is contained in:
SiboVG 2022-06-25 16:32:49 +02:00
parent 4d1e6165a8
commit 9191d9df51
3 changed files with 14 additions and 1 deletions

View File

@ -60,7 +60,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
}
/* Cached data */
final protected Map<Integer, StageFlags> stages = new HashMap<Integer, StageFlags>();
final protected Map<Integer, StageFlags> stages = new HashMap<Integer, StageFlags>(); // Map of stage number to StageFlags of the corresponding stage
final protected Map<MotorConfigurationId, MotorConfiguration> motors = new HashMap<MotorConfigurationId, MotorConfiguration>();
final private Collection<MotorConfiguration> activeMotors = new ArrayList<MotorConfiguration>();
final private InstanceMap activeInstances = new InstanceMap();

View File

@ -748,6 +748,14 @@ public class Rocket extends ComponentAssembly {
fireComponentChangeEvent(ComponentChangeEvent.TREE_CHANGE);
return nextConfig.getFlightConfigurationID();
}
/**
* Return all the flight configurations of this rocket.
* @return all the flight configurations of this rocket.
*/
public FlightConfigurableParameterSet<FlightConfiguration> getFlightConfigurations() {
return this.configSet;
}
/**

View File

@ -1545,6 +1545,11 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
AxialStage stage = (AxialStage) component;
this.getRocket().forgetStage(stage);
}
// Remove sub-stages of the removed component
for (AxialStage stage : component.getSubStages()) {
this.getRocket().forgetStage(stage);
}
this.checkComponentStructure();
component.checkComponentStructure();