mastodon-sc / mastodon

Mastodon – a large-scale tracking and track-editing framework for large, multi-view images.
BSD 2-Clause "Simplified" License
67 stars 20 forks source link

Use parent application Context when launched from said app. #48

Closed tinevez closed 6 years ago

tinevez commented 6 years ago

If Mastodon is launched via its Command interface, for instance when it is launched from the ImageJ2 plugins menu, it MUST get the Context of the parent app.

Before this commit, Mastodon was creating its own Context instance which caused a bug noticed by @tpietzsch:

"When run from Fiji, Mastodon somehow manages to disable the Command-Q shortcut for quitting (Fiji). This happens after a project is opened. Before (when only the MainWindow is open), it still works."

Actually quitting from Fiji after opening a project raised an exception caused indirectly by the two Context instances conflicting (details unknown, I did not investigate).

This commit fixes this issue by getting the Context instance from the command and passing it to where it is needed. If no Context is provided to the WindowManager, then it is allowed to create one.