Fix for Issue #122, NPE in RocketFigure3d.setType()
This problem will only happen when the RocketFigure3d is unable to create a GL canvas. It sets the canvas to null, but not all code that uses canvas checks for null. This class probably should handle this state better than it does, but this is the safe change now.
This commit is contained in:
parent
0bc139fd05
commit
11c5e072f0
@ -531,13 +531,15 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
||||
public void updateFigure() {
|
||||
log.debug("3D Figure Updated");
|
||||
cachedBounds = null;
|
||||
canvas.invoke(true, new GLRunnable() {
|
||||
@Override
|
||||
public boolean run(GLAutoDrawable drawable) {
|
||||
rr.updateFigure(drawable);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (canvas != null) {
|
||||
canvas.invoke(true, new GLRunnable() {
|
||||
@Override
|
||||
public boolean run(GLAutoDrawable drawable) {
|
||||
rr.updateFigure(drawable);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void internalRepaint() {
|
||||
@ -651,12 +653,17 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
||||
}
|
||||
|
||||
public void setType(final int t) {
|
||||
//There is no canvas if there was an error while creating it.
|
||||
if (canvas == null)
|
||||
return;
|
||||
|
||||
// The first time the user selects any 3d figure types, the canvas' internal _drawable
|
||||
// has not been realized. Unfortunately, there is a test in canvas.invoke which doesn't
|
||||
// execute the runnable if the drawable isn't realized.
|
||||
// In order to trump this, we test if the canvas has not been realized and initialize
|
||||
// the renderer accordingly. There is certainly a better way to do this.
|
||||
|
||||
|
||||
final RocketRenderer newRR;
|
||||
|
||||
switch (t) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user