updates for 0.9.3
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / CenteringRing.java
index 515667a5d11c4a6c861fb65b2bf9ad7ad1320a18..560cc260150a064ec02c281ca15bc539c461ee7a 100644 (file)
@@ -17,18 +17,21 @@ public class CenteringRing extends RadiusRingComponent {
                // Implement sibling inner radius automation
                if (isInnerRadiusAutomatic()) {
                        innerRadius = 0;
-                       for (RocketComponent sibling: this.getParent().getChildren()) {
-                               if (!(sibling instanceof RadialParent))  // Excludes itself
-                                       continue;
-
-                               double pos1 = this.toRelative(Coordinate.NUL, sibling)[0].x;
-                               double pos2 = this.toRelative(new Coordinate(getLength()), sibling)[0].x;
-                               if (pos2 < 0 || pos1 > sibling.getLength())
-                                       continue;
-                               
-                               innerRadius = Math.max(innerRadius, ((InnerTube)sibling).getOuterRadius());
+                       // Component can be parentless if disattached from rocket
+                       if (this.getParent() != null) {
+                               for (RocketComponent sibling: this.getParent().getChildren()) {
+                                       if (!(sibling instanceof RadialParent))  // Excludes itself
+                                               continue;
+                                       
+                                       double pos1 = this.toRelative(Coordinate.NUL, sibling)[0].x;
+                                       double pos2 = this.toRelative(new Coordinate(getLength()), sibling)[0].x;
+                                       if (pos2 < 0 || pos1 > sibling.getLength())
+                                               continue;
+                                       
+                                       innerRadius = Math.max(innerRadius, ((InnerTube)sibling).getOuterRadius());
+                               }
+                               innerRadius = Math.min(innerRadius, getOuterRadius());
                        }
-                       innerRadius = Math.min(innerRadius, getOuterRadius());
                }
                
                return super.getInnerRadius();