jshell: run cleanups on the client thread

This commit is contained in:
Max Weber
2021-07-16 15:52:57 -06:00
committed by Abex
parent 48c6434e6d
commit de8940b8b9

View File

@@ -419,18 +419,23 @@ public abstract class ShellPanel extends JPanel
private void cleanup() private void cleanup()
{ {
for (var c : cleanup) var todo = new ArrayList<>(cleanup);
{
try
{
c.run();
}
catch (Exception e)
{
shellLogger.error("Cleanup threw:", e);
}
}
cleanup.clear(); cleanup.clear();
invokeOnClientThread(() ->
{
for (var c : todo)
{
try
{
c.run();
}
catch (Exception e)
{
shellLogger.error("Cleanup threw:", e);
}
}
});
} }
protected abstract void invokeOnClientThread(Runnable r); protected abstract void invokeOnClientThread(Runnable r);