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>
  • Loading branch information
pkriens committed May 9, 2022
1 parent 499c74a commit e0ac1e2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bndtools.core/src/bndtools/explorer/Model.java
Expand Up @@ -102,12 +102,23 @@ 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) {}

if (dirty.getAndSet(false)) {
updates.forEach(Runnable::run);
}
Expand Down

0 comments on commit e0ac1e2

Please sign in to comment.