Skip to content

Commit

Permalink
Fix initialization of private variables in viewers
Browse files Browse the repository at this point in the history
_table in TableView and _dataobj in PlotView were not initialized
in the constructor.
  • Loading branch information
ejeschke committed Jun 7, 2024
1 parent d4f5454 commit 402d9bc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ginga/gw/PlotView.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def __init__(self, logger=None, settings=None):
else:
self.logger = logging.Logger('PlotView')

self._dataobj = None

# Create settings and set defaults
if settings is None:
settings = Settings.SettingGroup(logger=self.logger)
Expand Down
9 changes: 5 additions & 4 deletions ginga/rv/Channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,15 @@ def view_object(self, dataobj):
# if there is only one viewer available, use it otherwise
# pop-up a dialog and ask the user
if len(viewers) == 1:
self._open_with_viewer(viewers[0], dataobj)
self.open_with_viewer(viewers[0], dataobj)
return

msg = ("Multiple viewers are available for this data object. "
"Please select one.")
self.fv.gui_choose_viewer(msg, viewers, self._open_with_viewer,
self.fv.gui_choose_viewer(msg, viewers, self.open_with_viewer,
dataobj)

def _open_with_viewer(self, vinfo, dataobj):
def open_with_viewer(self, vinfo, dataobj):
# if we don't have this viewer type then install one in the channel
if vinfo.name not in self.viewer_dict:
self.fv.make_viewer(vinfo, self)
Expand All @@ -611,7 +611,8 @@ def _open_with_viewer(self, vinfo, dataobj):
self.widget.set_index(idx)

# and load the data
self.viewer.set_dataobj(dataobj)
if self.viewer.get_dataobj() is not dataobj:
self.viewer.set_dataobj(dataobj)

obj_name = dataobj.get('name')
if obj_name in self.image_index:
Expand Down
2 changes: 2 additions & 0 deletions ginga/table/TableView.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def __init__(self, logger=None, settings=None):
else:
self.logger = logging.Logger('TableViewBase')

self._table = None

# Create settings and set defaults
if settings is None:
settings = Settings.SettingGroup(logger=self.logger)
Expand Down
4 changes: 2 additions & 2 deletions ginga/util/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
viewer_db = {}


def register_viewer(vclass):
def register_viewer(vclass, priority=0):
"""Register a channel viewer.
Parameters
Expand All @@ -21,7 +21,7 @@ def register_viewer(vclass):
global viewer_db
viewer_db[vclass.vname] = Bunch.Bunch(name=vclass.vname,
vclass=vclass,
priority=0)
priority=priority)


def get_viewers(dataobj):
Expand Down

0 comments on commit 402d9bc

Please sign in to comment.