diff options
author | Sven Gothel <[email protected]> | 2015-08-29 19:41:10 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-08-29 19:41:10 +0200 |
commit | 7140081033444abf95d2f8289eaa62ead41cf2e0 (patch) | |
tree | 1a17920812a67f748b669ad8fc64b1d4b8523431 /src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java | |
parent | 472d97e821520235eb006f3c135df2f629494326 (diff) |
*AnimatorImpl: Catch concurrent pulling of GLAutoDrawable instances
It may happen that an GLAutoDrawable is being pulled concurrently from the
animators list, in which case an IndexOutOfBoundsException might be thrown.
Example:
[junit] *** AWTRobotUtil: UncaughtException (this Thread main-AWTAnimator#00) : Thread <main-AWTAnimator#00>, java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
[junit] java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
[junit] at java.util.ArrayList.rangeCheck(ArrayList.java:653)
[junit] at java.util.ArrayList.get(ArrayList.java:429)
[junit] at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:68)
[junit] at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:451)
[junit] at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:198)
[junit] at java.lang.Thread.run(Thread.java:745)
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java index 6cded29d9..d8c8465d9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java @@ -48,12 +48,19 @@ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl { public void display(final ArrayList<GLAutoDrawable> drawables, final boolean ignoreExceptions, final boolean printExceptions) throws UncaughtAnimatorException { - for (int i=0; i<drawables.size(); i++) { - final GLAutoDrawable drawable = drawables.get(i); + boolean hasException = false; + for (int i=0; !hasException && i<drawables.size(); i++) { + boolean catch1 = true; + GLAutoDrawable drawable = null; try { + drawable = drawables.get(i); + catch1 = false; drawable.display(); } catch (final Throwable t) { - if (ignoreExceptions) { + if( catch1 && t instanceof IndexOutOfBoundsException ) { + // concurrent pulling of GLAutoDrawables .. + hasException = true; + } else if (ignoreExceptions) { if (printExceptions) { t.printStackTrace(); } |