diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTreeNode.java b/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTreeNode.java index c8d2bb1a8..50d408e02 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTreeNode.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTreeNode.java @@ -32,7 +32,7 @@ public WorkspaceTreeNode(PathNode path) { * @return {@code true} when removal is a success. * {@code false} if nothing was removed. */ - public boolean removeNodeByPath(@Nonnull PathNode path) { + public synchronized boolean removeNodeByPath(@Nonnull PathNode path) { // Call from root node only. WorkspaceTreeNode root = this; while (root.getParent() instanceof WorkspaceTreeNode parentNode) @@ -65,7 +65,7 @@ public boolean removeNodeByPath(@Nonnull PathNode path) { * @return Node containing the path in the tree. */ @Nonnull - public WorkspaceTreeNode getOrCreateNodeByPath(@Nonnull PathNode path) { + public synchronized WorkspaceTreeNode getOrCreateNodeByPath(@Nonnull PathNode path) { // Call from root node only. WorkspaceTreeNode root = this; while (root.getParent() instanceof WorkspaceTreeNode parentNode) @@ -85,7 +85,7 @@ public WorkspaceTreeNode getOrCreateNodeByPath(@Nonnull PathNode path) { */ @Nullable @SuppressWarnings("deprecation") - public WorkspaceTreeNode getNodeByPath(@Nonnull PathNode path) { + public synchronized WorkspaceTreeNode getNodeByPath(@Nonnull PathNode path) { PathNode value = getValue(); if (path.equals(value)) return this; @@ -102,7 +102,7 @@ public WorkspaceTreeNode getNodeByPath(@Nonnull PathNode path) { */ @Nullable @SuppressWarnings("deprecation") - public WorkspaceTreeNode getFirstChild() { + public synchronized WorkspaceTreeNode getFirstChild() { return getChildren().isEmpty() ? null : getChildren().getFirst() instanceof WorkspaceTreeNode node ? node : null; @@ -136,7 +136,6 @@ public String toString() { return getClass().getSimpleName() + "[" + getValue().toString() + "]"; } - /** * Get/insert a {@link WorkspaceTreeNode} holding the given {@link PathNode} from/to the tree model. *