From 6dae530acc8d77bc51ccf16dbbef430b74611f02 Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Sat, 14 Mar 2020 20:01:54 -0700 Subject: [PATCH] Fix IllegalStateException when export/print Correct the logic for detecting if a motor has an invalid FlightConfigurationId and throw an IllegalStateException only in the case that it has an error. Additionally, fix the lookup for the stageMass. The wrong value was passed to the MassCalculator.getCGAnalysis(..) which resulted in a NullPointerException. Fixes #531 Signed-off-by: Billy Olsen --- swing/src/net/sf/openrocket/gui/print/DesignReport.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/print/DesignReport.java b/swing/src/net/sf/openrocket/gui/print/DesignReport.java index d95f9fb8f..9aeed6c2f 100644 --- a/swing/src/net/sf/openrocket/gui/print/DesignReport.java +++ b/swing/src/net/sf/openrocket/gui/print/DesignReport.java @@ -328,7 +328,7 @@ public class DesignReport { MassCalculator massCalc = new MassCalculator(); - if( !motorId.hasError() ){ + if( motorId.hasError() ){ throw new IllegalStateException("Attempted to add motor data with an invalid fcid"); } rocket.createFlightConfiguration(motorId); @@ -349,7 +349,7 @@ public class DesignReport { config.clearAllStages(); config.setOnlyStage(stage); stage++; - stageMass = massCalc.getCGAnalysis( config).get(stage).weight; + stageMass = massCalc.getCGAnalysis(config).get(c).weight; // Calculate total thrust-to-weight from only lowest stage motors totalTTW = 0; topBorder = true;