JBR-2159 Native crash in thread AWT-EventQueue-0 when trying to push commit

(cherry picked from commit bba297b4a4)
This commit is contained in:
Anton Tarasov
2020-02-21 10:16:06 +03:00
committed by jbrbot
parent 8953af676e
commit 669e34115a

View File

@@ -163,7 +163,20 @@ public class AWTThreading {
instance.invocations.push(new TrackingQueue());
}
final TrackingQueue queue = instance.invocations.peek();
InvocationEvent event = new InvocationEvent(source, runnable, listener, catchThrowables) {
Runnable safeListener = listener;
if (listener != null) {
// guarantees a single run of the passed 'listener'
safeListener = new Runnable() {
Runnable origListener = listener;
@Override
public void run() {
if (origListener != null) origListener.run();
origListener = null;
}
};
}
// guarantees a single dispatch of the event
InvocationEvent event = new InvocationEvent(source, runnable, safeListener, catchThrowables) {
final SoftReference<TrackingQueue> queueRef = new SoftReference<>(queue);
@Override