From fdbd861d91721aefb1025c2a13f2d3a7257a3f19 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Mon, 9 May 2022 15:41:17 +0200 Subject: [PATCH] #5062 JVM crash Another desperate attempt to fix the JVM crash in the bndtools explorer. This fix coalesces some update events by waiting 10 ms before starting to do the UI work. This should reduce the rate at which we call SWT and this _might_ solve this stupid SWT bug Signed-off-by: Peter Kriens --- bndtools.core/src/bndtools/explorer/Model.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bndtools.core/src/bndtools/explorer/Model.java b/bndtools.core/src/bndtools/explorer/Model.java index b03489ca34..929c2fe105 100644 --- a/bndtools.core/src/bndtools/explorer/Model.java +++ b/bndtools.core/src/bndtools/explorer/Model.java @@ -102,12 +102,27 @@ void onUpdate(Runnable runnable) { } void update() { - dirty.set(true); + if (dirty.getAndSet(true)) + return; + Display.getDefault() .asyncExec(this::update0); } + /* + * This runs async on the display thread. + */ private void update0() { + try { + // coalesce some more updates on + // the worker thread(s). + Thread.sleep(10); + } catch (InterruptedException e) { + Thread.currentThread() + .interrupt(); + return; + } + if (dirty.getAndSet(false)) { updates.forEach(Runnable::run); }