Skip to content

Commit

Permalink
Merge pull request #22 from astrofrog/restore-session-add-qt-specific…
Browse files Browse the repository at this point in the history
…-code

Add full implementation of __gluestate__and __setgluestate__ for application
  • Loading branch information
astrofrog authored Aug 19, 2024
2 parents de4f45c + 0236a60 commit 63991ae
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions 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)
state = super().__gluestate__(context)
state['viewers'] = [list(map(context.id, tab)) for tab in self.viewers]
state['tab_names'] = self.tab_names
return state

@classmethod
def __setgluestate__(cls, rec, context):
self = super(GlueApplication, cls).__setgluestate__(rec, context)
self = super().__setgluestate__(rec, context)

# COMPAT: removing the following if statement once we require#
# glue-core v1.22.0 or later
if sum(len(tab) for tab in self.viewers) > 0:
return self

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 63991ae

Please sign in to comment.