aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com/sun/opengl/impl/GLDrawableHelper.java')
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableHelper.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
index 8c9568381..e7fea1cee 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
@@ -55,6 +55,16 @@ public class GLDrawableHelper {
public GLDrawableHelper() {
}
+ public synchronized String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("GLEventListeners num "+listeners.size()+" [");
+ for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
public synchronized void addGLEventListener(GLEventListener listener) {
List newListeners = (List) ((ArrayList) listeners).clone();
newListeners.add(listener);
@@ -67,6 +77,15 @@ public class GLDrawableHelper {
listeners = newListeners;
}
+ public synchronized void dispose(GLAutoDrawable drawable) {
+ List newListeners = (List) ((ArrayList) listeners).clone();
+ for (Iterator iter = newListeners.iterator(); iter.hasNext(); ) {
+ ((GLEventListener) iter.next()).dispose(drawable);
+ iter.remove();
+ }
+ listeners = newListeners;
+ }
+
public void init(GLAutoDrawable drawable) {
for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
((GLEventListener) iter.next()).init(drawable);
@@ -117,12 +136,14 @@ public class GLDrawableHelper {
try {
res = context.makeCurrent();
if (res != GLContext.CONTEXT_NOT_CURRENT) {
- perThreadInitAction.set(initAction);
- if (res == GLContext.CONTEXT_CURRENT_NEW) {
- if (DEBUG) {
- System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction");
- }
- initAction.run();
+ if(null!=initAction) {
+ perThreadInitAction.set(initAction);
+ if (res == GLContext.CONTEXT_CURRENT_NEW) {
+ if (DEBUG) {
+ System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction");
+ }
+ initAction.run();
+ }
}
if (DEBUG && VERBOSE) {
System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable");