Safeguard against infinite loops in getThreadAncestors()

When we try to help ImageJ 1.x read its macro options, we traverse the
parent threads until we find one with macro options, or until the chain of
parent threads is broken.

There are subtle ways, however, to have infinite loops there.

Instead of looping indefinitely, just stop when we had a look at all
available threads in the parent chain.

This problem could be triggered reliably by switching to modern mode and
then hitting the "o" key to open a file.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
DefaultLegacyOpener: Avoid triggering ImageJ 1.x bug

There is a bug in at least version 1.49b of legacy ImageJ in that
the ImagePlus tries to cast the ImageWindow associated with a
CompositeImage to the StackWindow subclass. The assumption that
hyperstacks or composite images are displayed in a StackWindow is
wrong, however, if the stack size is one.

Therefore, much to this developer's chagrin, we have to continue the
inconsistency of returning sometimes composite images, sometimes not.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge branch 'composite-images'

This branch fixes two issues: one reported with 16-bit images loaded
via SCIFIO (triggering an ImageJ 1.x bug where it assumes that every
CompositeImage has a StackWindow, or no window at all), and an infinite
loop when working around ImageJ 1.x' single-thread limitation of the
macro options.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>