Browse Source

Dispatch events on a copy of the listener list

This allows for listeners to be removed/added while dispatching.
modulesv2
weisj 3 years ago
parent
commit
9a31cbdc52
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 4
      theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemeEventSupport.java

4
theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemeEventSupport.java

@ -43,8 +43,10 @@ public class ThemeEventSupport<E extends ThemeEvent, T extends ThemeEventListene
}
public void dispatchEvent(final E event, final BiConsumer<T, E> consumer) {
listenerList.forEach(listener -> {
synchronized (listenerList) {
new ArrayList<>(listenerList).forEach(listener -> {
if (listener != null) consumer.accept(listener, event);
});
}
}
}

Loading…
Cancel
Save