From 428fd83d365ed5bfc2ad8016e7f2b03f0401334b Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 16 Aug 2024 12:19:36 +0100 Subject: [PATCH] Added full implementation of __gluestate__ and __setgluestate__ for application --- glue_qt/app/application.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/glue_qt/app/application.py b/glue_qt/app/application.py index 5fe26d93..936f2368 100644 --- a/glue_qt/app/application.py +++ b/glue_qt/app/application.py @@ -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