Skip to content

Commit

Permalink
bndtools#5062 JVM crash
Browse files Browse the repository at this point in the history
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 <Peter.Kriens@aqute.biz>
Signed-off-by: BJ Hargrave <bj@hargrave.dev>
  • Loading branch information
pkriens authored and bjhargrave committed May 19, 2022
1 parent 6a99d27 commit ea24b46
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bndtools.core/src/bndtools/explorer/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit ea24b46

Please sign in to comment.