Skip to content

A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.

Opening a project: a tool's state is put back on the event thread

scottsturrockf6816b2da969
diff --git a/src/opensuite/ui/StateIO.java b/src/opensuite/ui/StateIO.java
index d28d5c4..a10fc36 100644
--- a/src/opensuite/ui/StateIO.java
+++ b/src/opensuite/ui/StateIO.java
@@ -584,11 +584,26 @@ public final class StateIO {
ctx.holdToolState(saved.getKey(), saved.getValue());
continue;
}
- try { t.restoreState(saved.getValue()); }
- catch (Exception ex) {
- // Name the tool: a panel that comes up empty after a project
- // opens is otherwise mystifying.
- Debug.error("tool '" + t.name() + "' failed to restore its saved state", ex);
+ // A tool puts its state back into its own components, so this is done
+ // on the event thread. A project is read on a thread of its own, and a
+ // tool filling a text box from there while the window laid itself out
+ // could leave each waiting for the other, with the window frozen on
+ // "Reading ...".
+ Runnable put = () -> {
+ try { t.restoreState(saved.getValue()); }
+ catch (Exception ex) {
+ // Name the tool: a panel that comes up empty after a project
+ // opens is otherwise mystifying.
+ Debug.error("tool '" + t.name() + "' failed to restore its saved state", ex);
+ }
+ };
+ if (SwingUtilities.isEventDispatchThread()) put.run();
+ else {
+ try { SwingUtilities.invokeAndWait(put); }
+ catch (InterruptedException ex) { Thread.currentThread().interrupt(); return; }
+ catch (java.lang.reflect.InvocationTargetException ex) {
+ Debug.error("tool '" + t.name() + "' failed to restore its saved state", ex.getCause());
+ }
}
}
}