Skip to content

Commit

Permalink
Return on missing attr
Browse files Browse the repository at this point in the history
  • Loading branch information
duytnguyendtn committed Oct 11, 2024
1 parent d14a4ab commit 3715e4b
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,23 @@ def __init__(self, *args, **kwargs):
@observe("viewer_selected", type="change")
def vue_viewer_changed(self, _=None):
# Check mixin object initialized
if hasattr(self, "viewer"):
# Clear all existing subscriptions and resubscribe to selected viewer
for viewer in self.viewer.viewers:
if viewer == self.viewer.selected_obj:
viewer.state.add_callback("zoom_center_x", self.vue_center_on_data)
viewer.state.add_callback("zoom_center_y", self.vue_center_on_data)
else:
# If not subscribed anyways, remove_callback should produce a no-op
viewer.state.remove_callback(
"zoom_center_x", self.vue_center_on_data
)
viewer.state.remove_callback(
"zoom_center_y", self.vue_center_on_data
)
self.vue_center_on_data()
if not hasattr(self, "viewer"):
return

# Clear all existing subscriptions and resubscribe to selected viewer
for viewer in self.viewer.viewers:
if viewer == self.viewer.selected_obj:
viewer.state.add_callback("zoom_center_x", self.vue_center_on_data)
viewer.state.add_callback("zoom_center_y", self.vue_center_on_data)
else:
# If not subscribed anyways, remove_callback should produce a no-op
viewer.state.remove_callback(
"zoom_center_x", self.vue_center_on_data
)
viewer.state.remove_callback(
"zoom_center_y", self.vue_center_on_data
)
self.vue_center_on_data()

@observe("coord_follow_viewer_pan", type="change")
def _toggle_viewer_pan_tracking(self, _=None):
Expand Down

0 comments on commit 3715e4b

Please sign in to comment.