Skip to content

Conversation

@frauzufall
Copy link
Member

@frauzufall frauzufall commented May 28, 2020

  • both the convertService and the objectService attach objects of a
    given type to the result list of AbstractInputHarvester:getObjects
  • this results into the same objects being in the list twice
  • using a set avoids duplicates in the list

Example for testing:

@Plugin(type = Command.class)
public class TestCommand implements Command {

    @Parameter
    private Img input;

    @Parameter
    private Img input2;

    @Override
    public void run() {}

    public static void main(final String... args) throws Exception {
        final ImageJ ij = new ImageJ();
        ij.ui().showUI();
        Object img = ij.io().open("/home/random/blobs.tif");
        ij.ui().show(img);
        ij.command().run(TestCommand.class, true);
    }
}

* both the convertService and the objectService attach objects of a
given type to the result list of AbstractInputHarvester:getObjects
* this results into the same objects being in the list twice
* using a set avoids duplicates in the list
@imagejan
Copy link
Member

Thanks @frauzufall for investigating!

This might be part of a solution for imagej/imagej-legacy#230.

@frauzufall frauzufall requested a review from ctrueden June 12, 2020 23:31
@frauzufall
Copy link
Member Author

@ctrueden this might help fix macro recorder issues though I had no time to confirm this yet. But since it's only a small change fixing an issue which multiple people have told me about, it would be great to merge this.

@ctrueden ctrueden merged commit 73743b0 into master Jun 19, 2020
@ctrueden
Copy link
Member

Awesome @frauzufall! This has been a loooongstanding bug. Thanks for fixing it! And sorry I missed it till now.

@ctrueden ctrueden deleted the fix-object-widget-duplication branch June 19, 2020 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants