Skip to content

Commit

Permalink
Fix issues with handling of root objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ObaraEmmanuel committed Jan 20, 2022
1 parent cf4993b commit a88814e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions formation/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class CanvasLoaderAdapter(BaseLoaderAdapter):
def load(cls, node, builder, parent):
canvas = BaseLoaderAdapter.load(node, builder, parent)
for sub_node in node:
if sub_node.type in builder._ignore_tags:
continue
# just additional options that may be needed down the line
kwargs = {
"parent_node": sub_node.parent,
Expand Down
2 changes: 1 addition & 1 deletion studio/feature/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def delete(self, widget, silently=False):
# try finding another toplevel widget that can be a root obj otherwise leave it as none
self.root_obj = None
for w in self.layout_strategy.children:
if isinstance(w, Container):
if isinstance(w, Container) or w.group == Groups.container:
self.root_obj = w
break
self._uproot_widget(widget)
Expand Down
2 changes: 1 addition & 1 deletion studio/parsers/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def generate(self):
other widgets at the root level are ignored and cannot be recovered later
:return:
"""
adapter = self.get_adapter(self.root.__class__)
adapter = self.get_adapter(self.designer.root_obj.__class__)
self.root = adapter.generate(self.designer.root_obj, None)
# load meta and variables first
self._meta_to_tree(self.root)
Expand Down
3 changes: 2 additions & 1 deletion studio/tools/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,8 @@ def load(cls, node, designer, parent, bounds=None):
cls._tool.initialize_canvas(widget)
for sub_node in node:
if sub_node.type not in CANVAS_ITEM_MAP:
raise NotImplementedError(f"Tag <{sub_node.type}> not implemented by canvas tool")
# ignore non canvas items
continue
# use a copy just in case something gets popped down the line
config = dict(sub_node.attrib.get("attr", {}))
# add name to config as id so the intercepts can set it for us
Expand Down

0 comments on commit a88814e

Please sign in to comment.