imagej / imagej2

Open scientific N-dimensional image processing :microscope: :sparkler:
https://imagej.net/
BSD 2-Clause "Simplified" License
1.2k stars 337 forks source link

OptionsPlugins cannot be opened a second time after accepting or cancelling #163

Open omaraa opened 7 years ago

omaraa commented 7 years ago

To reproduce:

  1. Open the OptionsLookAndFeel plugin (Edit >> Options >> Look and Feel...)
  2. Press Cancel
  3. Open the OptionsLookAndFeel plugin a second time
    • Plugin does not open and IJ status bar shows message "Command cancelled: Look and Feel..."

This issue affects all plugins extending OptionsPlugin.

imagejan commented 7 years ago

This is a scijava-commons issue and likely due to the cancelReason not being reset on subsequent runs of a org.scijava.command.DynamicCommand, see these lines.

ctrueden commented 7 years ago

Thanks for the report, @omaraa. I confirm this bug occurs with the latest ImageJ, 2.0.0-rc-59.

ctrueden commented 7 years ago

@imagejan Right, because OptionsPlugin extends DynamicCommand and implements SingletonPlugin—i.e.: there is only one instance of each OptionsPlugin per context. But one of the preconditions of commands is that they only run once per instance lifetime. So we need to make an architectural decision here about the best way to proceed. As things stand, options plugins are a dirty hack.