aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-08-29 19:41:10 +0200
committerSven Gothel <[email protected]>2015-08-29 19:41:10 +0200
commit7140081033444abf95d2f8289eaa62ead41cf2e0 (patch)
tree1a17920812a67f748b669ad8fc64b1d4b8523431 /src/jogl/classes/com/jogamp/opengl/util
parent472d97e821520235eb006f3c135df2f629494326 (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')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java48
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java13
2 files changed, 37 insertions, 24 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
index 76d64963f..9e9cc8e44 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
@@ -56,7 +56,7 @@ import com.jogamp.opengl.util.AnimatorBase.UncaughtAnimatorException;
class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl {
// For efficient rendering of Swing components, in particular when
// they overlap one another
- private final List<JComponent> lightweights = new ArrayList<JComponent>();
+ private final List<JComponent> lightweights = new ArrayList<JComponent>();
private final Map<RepaintManager,RepaintManager> repaintManagers = new IdentityHashMap<RepaintManager,RepaintManager>();
private final Map<JComponent,Rectangle> dirtyRegions = new IdentityHashMap<JComponent,Rectangle>();
@@ -64,34 +64,40 @@ class AWTAnimatorImpl 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);
- if (drawable instanceof JComponent) {
- // Lightweight components need a more efficient drawing
- // scheme than simply forcing repainting of each one in
- // turn since drawing one can force another one to be
- // drawn in turn
- lightweights.add((JComponent)drawable);
- } else {
- try {
+ boolean hasException = false;
+ for (int i=0; !hasException && i<drawables.size(); i++) {
+ GLAutoDrawable drawable = null;
+ boolean catch1 = true;
+ try {
+ drawable = drawables.get(i);
+ catch1 = false;
+ if (drawable instanceof JComponent) {
+ // Lightweight components need a more efficient drawing
+ // scheme than simply forcing repainting of each one in
+ // turn since drawing one can force another one to be
+ // drawn in turn
+ lightweights.add((JComponent)drawable);
+ } else {
drawable.display();
- } catch (final Throwable t) {
- if (ignoreExceptions) {
- if (printExceptions) {
- t.printStackTrace();
- }
- } else {
- throw new UncaughtAnimatorException(drawable, t);
+ }
+ } catch (final Throwable t) {
+ if( catch1 && t instanceof IndexOutOfBoundsException ) {
+ // concurrent pulling of GLAutoDrawables ..
+ hasException = true;
+ } else if ( ignoreExceptions ) {
+ if ( printExceptions ) {
+ t.printStackTrace();
}
+ } else {
+ throw new UncaughtAnimatorException(drawable, t);
}
}
}
-
if (lightweights.size() > 0) {
try {
SwingUtilities.invokeAndWait(drawWithRepaintManagerRunnable);
- } catch (final Exception e) {
- e.printStackTrace();
+ } catch (final Throwable t) {
+ t.printStackTrace();
}
lightweights.clear();
}
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();
}