summaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/GLDrawableHelper.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2004-04-08 19:04:23 +0000
committerKenneth Russel <[email protected]>2004-04-08 19:04:23 +0000
commitf90ab644c419486f7894fda3725a9c81de8bb283 (patch)
treefba6e3c693cbaf620f9be5d0dfb853cf7ae789d5 /src/net/java/games/jogl/impl/GLDrawableHelper.java
parent0a2874e6d6a69e3f5c8392402ad1d520adf37b23 (diff)
Fixed Issue 25: Expose swapBuffers(), please
Fixed Issue 31: Make it safe to remove listeners from a GLDrawable while handling an event git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@93 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/GLDrawableHelper.java')
-rw-r--r--src/net/java/games/jogl/impl/GLDrawableHelper.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/net/java/games/jogl/impl/GLDrawableHelper.java b/src/net/java/games/jogl/impl/GLDrawableHelper.java
index 89800e684..775fffdd6 100644
--- a/src/net/java/games/jogl/impl/GLDrawableHelper.java
+++ b/src/net/java/games/jogl/impl/GLDrawableHelper.java
@@ -46,39 +46,39 @@ import net.java.games.jogl.*;
methods to be able to share it between GLCanvas and GLJPanel. */
public class GLDrawableHelper {
- private List listeners = new ArrayList();
+ private volatile List listeners = new ArrayList();
public GLDrawableHelper() {
}
- public void addGLEventListener(GLEventListener listener) {
- listeners.add(listener);
+ public synchronized void addGLEventListener(GLEventListener listener) {
+ List newListeners = (List) ((ArrayList) listeners).clone();
+ newListeners.add(listener);
+ listeners = newListeners;
}
- public void removeGLEventListener(GLEventListener listener) {
- listeners.remove(listener);
+ public synchronized void removeGLEventListener(GLEventListener listener) {
+ List newListeners = (List) ((ArrayList) listeners).clone();
+ newListeners.remove(listener);
+ listeners = newListeners;
}
public void init(GLDrawable drawable) {
- // Note that we don't use iterator() since listeners may
- // add/remove other listeners during initialization. We don't
- // guarantee that all listeners will be evaluated if
- // removeGLEventListener is called.
- for (int i = 0; i < listeners.size(); i++) {
- ((GLEventListener) listeners.get(i)).init(drawable);
+ for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
+ ((GLEventListener) iter.next()).init(drawable);
}
}
public void display(GLDrawable drawable) {
- for (int i = 0; i < listeners.size(); i++) {
- ((GLEventListener) listeners.get(i)).display(drawable);
+ for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
+ ((GLEventListener) iter.next()).display(drawable);
}
}
public void reshape(GLDrawable drawable,
int x, int y, int width, int height) {
- for (int i = 0; i < listeners.size(); i++) {
- ((GLEventListener) listeners.get(i)).reshape(drawable, x, y, width, height);
+ for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
+ ((GLEventListener) iter.next()).reshape(drawable, x, y, width, height);
}
}
}