Skip to content

Commit

Permalink
Added full implementation of __gluestate__ and __setgluestate__ for a…
Browse files Browse the repository at this point in the history
…pplication
  • Loading branch information
astrofrog committed Aug 16, 2024
1 parent dbe9bf1 commit 428fd83
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion glue_qt/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,13 +1445,26 @@ def add_datasets(self, *args, **kwargs):
return result

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

@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)
self = super(GlueApplication, cls).__setgluestate__(rec, context)
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)
if 'tab_names' in rec:
self.tab_names = rec['tab_names']
return self

0 comments on commit 428fd83

Please sign in to comment.