diff options
author | Sven Gothel <[email protected]> | 2011-03-25 23:39:17 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-03-25 23:39:17 +0100 |
commit | 14c193e2ec44f6bcff6dfffa85042518e364478c (patch) | |
tree | 1a37be98b39f179b88b1c8222f0b53801ffd32a2 /src | |
parent | ed79607e888dcb73f5ee17cde85149a3d963325b (diff) |
FPSAnimator: Avoid NPE
Diffstat (limited to 'src')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 741d4461b..284e2bcc9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -116,6 +116,9 @@ public class FPSAnimator extends AnimatorBase { } private void startTask() { + if(null != task) { + return; + } long delay = (long) (1000.0f / (float) fps); task = new TimerTask() { public void run() { @@ -161,10 +164,14 @@ public class FPSAnimator extends AnimatorBase { stateSync.lock(); try { shouldRun = false; - task.cancel(); - task = null; - timer.cancel(); - timer = null; + if(null != task) { + task.cancel(); + task = null; + } + if(null != timer) { + timer.cancel(); + timer = null; + } animThread = null; } finally { stateSync.unlock(); @@ -179,8 +186,10 @@ public class FPSAnimator extends AnimatorBase { stateSync.lock(); try { shouldRun = false; - task.cancel(); - task = null; + if(null != task) { + task.cancel(); + task = null; + } animThread = null; } finally { stateSync.unlock(); |