When deleting a flight configuration, first change the configuration to

a different one.
This commit is contained in:
kruland2607 2013-10-09 16:06:30 -05:00
parent 1e0ac22592
commit 6641f959c5
2 changed files with 7 additions and 1 deletions

View File

@ -545,7 +545,14 @@ public class Rocket extends RocketComponent {
checkState(); checkState();
if (id == null) if (id == null)
return; return;
// Get current configuration:
String currentId = getDefaultConfiguration().getFlightConfigurationID();
// If we're removing the current configuration, we need to switch to a different one first.
if (currentId != null && currentId.equals(id)) {
getDefaultConfiguration().setFlightConfigurationID(null);
}
flightConfigurationIDs.remove(id); flightConfigurationIDs.remove(id);
// FIXME - remove corresponding simulations?
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
} }

View File

@ -156,7 +156,6 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
if (currentId == null) if (currentId == null)
return; return;
rocket.removeFlightConfigurationID(currentId); rocket.removeFlightConfigurationID(currentId);
rocket.getDefaultConfiguration().setFlightConfigurationID(null);
configurationChanged(); configurationChanged();
} }