Skip to content

Commit

Permalink
fix: don't add a node path to itself
Browse files Browse the repository at this point in the history
* avoid stack overflow
* and be quiet
  • Loading branch information
bogovicj committed Oct 17, 2023
1 parent d6e2cc5 commit 3b5791d
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,13 @@ private void openContainer(final Function<String, N5Reader> n5Fun, final Supplie

n5 = n5Fun.apply(n5Path);
final String rootPath = pathToRoot.apply(n5Path);
System.out.println("rootPath: " + rootPath);

if (n5 == null) {
messageLabel.setVisible(false);
dialog.repaint();
return;
}


// copy list
final ArrayList<N5MetadataParser<?>> parserList = new ArrayList<>();

Expand Down Expand Up @@ -680,10 +678,14 @@ private void openContainer(final Function<String, N5Reader> n5Fun, final Supplie
final Consumer<N5TreeNode> callback = (x) -> {
SwingUtilities.invokeLater(() -> {
if (x.getMetadata() != null) {
// get the node at the requested path, or add it if not
// present
// get the node at the requested path, or add it if not present
final N5SwingTreeNode node = (N5SwingTreeNode)rootNode.getDescendants(y -> pathsEqual(y.getPath(), x.getPath())).findFirst()
.orElse(rootNode.addPath(x.getPath()));
.orElseGet( () -> {
if (rootNode.getPath().equals(x.getPath()))
return null;
else
return rootNode.addPath(x.getPath());
});

// update the node's metadata
if (node != null) {
Expand Down

0 comments on commit 3b5791d

Please sign in to comment.