imagej / ij1-patcher

Extension points for ImageJ via runtime patching to support (limited) headless operation and ImageJ2's legacy layer
BSD 2-Clause "Simplified" License
5 stars 6 forks source link

Address two issues with Macro.getOptions() #27

Closed dscho closed 10 years ago

dscho commented 10 years ago

The design of Macro.getOptions() demonstrates that ImageJ 1.x was really designed as a single-thread application: if you launch another thread from a plugin and call a GenericDialog, it will no longer see the macro options.

In general, one can work around that by forcing the macro options to be set again inside the newly spawned thread (and ensure that the thread name starts with Run$_ for some reason). But in SciJava's ThreadService, a thread pool is used, so that option is out.

This PR allows legacy hooks to provide additional information about thread relationships (essentially looking through the entire thread ancestor list to find the macro options), and it also removes the limitation that macro options are only seen when the current thread's name starts with a magic prefix.

ctrueden commented 10 years ago

I probably would have gone with getThreadAncestors() returning a List<Thread> but using Iterable<Thread> is more general.

dscho commented 10 years ago

It is not only more general, it is also safer: thread relationships could change in the meantime ;-)