Fix selection bug in motor selection panel. The app threw NPE when
trying to reuse the dialog.
This commit is contained in:
		
							parent
							
								
									11328bc1fc
								
							
						
					
					
						commit
						581ec324d9
					
				| @ -310,6 +310,10 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void setMotorMountAndConfig( MotorMount mount, String currentConfig ) { | 	public void setMotorMountAndConfig( MotorMount mount, String currentConfig ) { | ||||||
|  | 		selectedMotor = null; | ||||||
|  | 		selectedMotorSet = null; | ||||||
|  | 		selectedDelay = 0; | ||||||
|  | 		 | ||||||
| 		ThrustCurveMotor motorToSelect = null; | 		ThrustCurveMotor motorToSelect = null; | ||||||
| 		if (currentConfig != null && mount != null) { | 		if (currentConfig != null && mount != null) { | ||||||
| 			MotorConfiguration motorConf = mount.getMotorConfiguration().get(currentConfig); | 			MotorConfiguration motorConf = mount.getMotorConfiguration().get(currentConfig); | ||||||
| @ -317,21 +321,14 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec | |||||||
| 			selectedDelay = motorConf.getEjectionDelay(); | 			selectedDelay = motorConf.getEjectionDelay(); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		selectedMotorSet = null; |  | ||||||
| 		 |  | ||||||
| 		// If current motor is not found in db, add a new ThrustCurveMotorSet containing it | 		// If current motor is not found in db, add a new ThrustCurveMotorSet containing it | ||||||
| 		if (motorToSelect != null) { | 		if (motorToSelect != null) { | ||||||
| 			for (ThrustCurveMotorSet motorSet : database) { | 			ThrustCurveMotorSet motorSetToSelect = null; | ||||||
| 				if (motorSet.getMotors().contains(motorToSelect)) { | 			motorSetToSelect = findMotorSet(motorToSelect); | ||||||
| 					selectedMotorSet = motorSet; | 			if (motorSetToSelect == null) { | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			if (selectedMotorSet == null) { |  | ||||||
| 				database = new ArrayList<ThrustCurveMotorSet>(database); | 				database = new ArrayList<ThrustCurveMotorSet>(database); | ||||||
| 				ThrustCurveMotorSet extra = new ThrustCurveMotorSet(); | 				ThrustCurveMotorSet extra = new ThrustCurveMotorSet(); | ||||||
| 				extra.addMotor(motorToSelect); | 				extra.addMotor(motorToSelect); | ||||||
| 				selectedMotorSet = extra; |  | ||||||
| 				database.add(extra); | 				database.add(extra); | ||||||
| 				Collections.sort(database); | 				Collections.sort(database); | ||||||
| 			} | 			} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user