Skip to content

Commit

Permalink
Merge pull request #2510 from astrofrog/restore-session
Browse files Browse the repository at this point in the history
Remove viewer-specific code from __gluestate__ and __setgluestate__ on base Application class
  • Loading branch information
astrofrog authored Aug 16, 2024
2 parents 6cb7094 + 41582d5 commit e9df453
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion glue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def __getitem__(self, cmap_name):

def name_from_cmap(self, cmap_desired):
for name, cmap in self.members:
if cmap is cmap_desired:
if cmap is cmap_desired or cmap.name == cmap_desired.name:
return name
raise ValueError("Could not find name for colormap")

Expand Down
12 changes: 3 additions & 9 deletions glue/core/application_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,22 +352,16 @@ def set_data_color(self, color, alpha):
data.style.alpha = alpha

def __gluestate__(self, context):
viewers = [list(map(context.id, tab)) for tab in self.viewers]
data = self.session.data_collection
from glue.main import _loaded_plugins
return dict(session=context.id(self.session), viewers=viewers,
data=context.id(data), plugins=_loaded_plugins)
return dict(session=context.id(self.session),
data=context.id(data),
plugins=_loaded_plugins)

@classmethod
def __setgluestate__(cls, rec, context):
self = cls(data_collection=context.object(rec['data']))
# manually register the newly-created session, which
# the viewers need
context.register_object(rec['session'], self.session)
for i, tab in enumerate(rec['viewers']):
if self.tab(i) is None:
self.new_tab()
for v in tab:
viewer = context.object(v)
self.add_widget(viewer, tab=i, hold_position=True)
return self

0 comments on commit e9df453

Please sign in to comment.