gemini-hlsw/ocs — pull request #105 by swalker2m (2014-11-19 20:27:13+00:00)
Title: REL-2121: NPE in TPE offset feature unload

This PR addresses a `NullPointerException` in the OT TPE. It will happen when the first observation displayed in the TPE does not have offset positions. There are two substantive changes:

* `TpeImageFeature` implementations in general do not assume that the feature has been properly initialized in their `unloaded` methods. A quick look at all image feature implementations except `EdIterOffsetFeature` confirms this. Unfortunately `EdIterOffsetFeature` trys to access the image widget to set a flag in its `unloaded` method:

`_iw.setViewingOffsets(false);`

This has been protected by a `null` check.

* Next I looked into why the `EdIterOffsetFeature` had been loaded in the first place and found that it was an unintended consequence of setting selection preferences on startup. Setting the preference triggers an item listener which adds the feature to the image widget even though the TPE hasn't been fully initialized. I moved the button selection before the item listener is established to avoid this issue.