Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add full implementation of __gluestate__and __setgluestate__ for application #22

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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()

Check warning on line 1464 in glue_qt/app/application.py

View check run for this annotation

Codecov / codecov/patch

glue_qt/app/application.py#L1464

Added line #L1464 was not covered by tests
for v in tab:
viewer = context.object(v)
self.add_widget(viewer, tab=i, hold_position=True)

Check warning on line 1467 in glue_qt/app/application.py

View check run for this annotation

Codecov / codecov/patch

glue_qt/app/application.py#L1466-L1467

Added lines #L1466 - L1467 were not covered by tests
if 'tab_names' in rec:
self.tab_names = rec['tab_names']
return self
Loading