diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 9ae7855bf..d33dd8b77 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -1355,7 +1355,7 @@ public class PApplet implements PConstants { class RegisteredMethods { Queue entries = new ConcurrentLinkedQueue<>(); - + Set removals = null; final Object[] emptyArgs = new Object[] { }; @SuppressWarnings("unused") @@ -1364,6 +1364,11 @@ public class PApplet implements PConstants { } void handle(Object[] args) { + // Queue removed entries until done iterating, i.e. so the Video Library + // can call unregisterMethod("dispose") from inside its dispose() method + // https://github.com/processing/processing4/pull/199 + removals = ConcurrentHashMap.newKeySet(); + for (RegisteredMethod entry : entries) { try { //methods[i].invoke(objects[i], args); @@ -1387,6 +1392,11 @@ public class PApplet implements PConstants { } } } + // Clear the entries queued for removal (if any) + for (Object object : removals) { + entries.remove(object); + } + removals = null; // clear this out } @@ -1406,7 +1416,12 @@ public class PApplet implements PConstants { * Does not shrink array afterwards, silently returns if method not found. */ public void remove(Object object) { - entries.remove(object); + if (removals != null) { + entries.remove(object); + } else { + // Currently iterating the list of methods, remove this afterwards + removals.add(object); + } } } diff --git a/core/todo.txt b/core/todo.txt index d5b75b4be..428cdcb96 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -5,6 +5,18 @@ X https://github.com/processing/processing4/issues/179 X https://github.com/processing/processing4/issues/192 X update the batik url X https://github.com/processing/processing4/pull/183 +X calling unregisterMethod() on dispose from dispose() means concurrent mod +o https://github.com/processing/processing4/pull/199 +X modernized the code a bit, checked in a version that queues to avoid list issue + + +_ PImage.resize() not working +_ https://github.com/processing/processing4/issues/200 +_ two simple examples added to the issue that can be used for tests + +_ mouseButton not set correctly on mouseReleased() with Java2D +_ https://github.com/processing/processing4/issues/181 +_ https://github.com/processing/processing4/pull/188 _ why does japplemenubar.JAppleMenuBar.hide(); still work?