Merge pull request #1201 from SiboVG/issues-1163
[fixes #1163 & #1175] Fix unreliable simulation creation from new flight config
This commit is contained in:
commit
7e14a07f9b
@ -170,7 +170,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
* create simulation for new configuration
|
||||
*/
|
||||
private void addOrCopyConfiguration(boolean copy) {
|
||||
Map<FlightConfigurationId, FlightConfiguration> newConfigs = new LinkedHashMap<>();
|
||||
final Map<FlightConfigurationId, FlightConfiguration> newConfigs = new LinkedHashMap<>();
|
||||
|
||||
// create or copy configuration
|
||||
if (copy) {
|
||||
@ -198,20 +198,22 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
newConfigs.put(newId, newConfig);
|
||||
}
|
||||
|
||||
for (FlightConfigurationId newId : newConfigs.keySet()) {
|
||||
OpenRocketDocument doc = BasicFrame.findDocument(rocket);
|
||||
if (doc == null) return;
|
||||
|
||||
for (Map.Entry<FlightConfigurationId, FlightConfiguration> config : newConfigs.entrySet()) {
|
||||
// associate configuration with Id and select it
|
||||
rocket.setFlightConfiguration(newId, newConfigs.get(newId));
|
||||
rocket.setFlightConfiguration(config.getKey(), config.getValue());
|
||||
rocket.setSelectedConfiguration(config.getKey());
|
||||
|
||||
// create simulation for configuration
|
||||
Simulation newSim = new Simulation(rocket);
|
||||
|
||||
OpenRocketDocument doc = BasicFrame.findDocument(rocket);
|
||||
if (doc != null) {
|
||||
newSim.setName(doc.getNextSimulationName());
|
||||
doc.addSimulation(newSim);
|
||||
}
|
||||
newSim.setName(doc.getNextSimulationName());
|
||||
doc.addSimulation(newSim);
|
||||
}
|
||||
|
||||
// Reset to first selected flight config
|
||||
rocket.setSelectedConfiguration((FlightConfigurationId) newConfigs.keySet().toArray()[0]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user