Mercurial > libervia-backend
diff sat_frontends/tools/xmlui.py @ 2995:5ecce65631a2
frontends (xmlui): fixed crash when CURRENT_LABEL is None:
fix 323
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 11 Jul 2019 09:21:10 +0200 |
parents | 5ba98fd6c9a4 |
children | ab2696e34d29 |
line wrap: on
line diff
--- a/sat_frontends/tools/xmlui.py Tue Jul 09 09:06:45 2019 +0200 +++ b/sat_frontends/tools/xmlui.py Thu Jul 11 09:21:10 2019 +0200 @@ -466,6 +466,10 @@ elif type_ == "label": cont = self.widget_factory.createLabelContainer(_xmlui_parent) self._parseChilds( + # FIXME: the "None" value for CURRENT_LABEL doesn't seem + # used or even useful, it should probably be removed + # and all "is not None" tests for it should be removed too + # to be checked for 0.8 cont, node, ("widget", "container"), {CURRENT_LABEL: None} ) elif type_ == "advanced_list": @@ -541,8 +545,10 @@ ): # current widget is ignored, but there may be already a label if CURRENT_LABEL in data: - # if so, we remove it from parent - _xmlui_parent._xmluiRemove(data.pop(CURRENT_LABEL)) + curr_label = data.pop(CURRENT_LABEL) + if curr_label is not None: + # if so, we remove it from parent + _xmlui_parent._xmluiRemove(curr_label) continue type_ = node.getAttribute("type") value_elt = self._getChildNode(node, "value") @@ -689,9 +695,11 @@ ctrl._xmlui_name = name _xmlui_parent._xmluiAppend(ctrl) if CURRENT_LABEL in data and not isinstance(ctrl, LabelWidget): - # this key is set in LabelContainer, when present - # we can associate the label with the widget it is labelling - data.pop(CURRENT_LABEL)._xmlui_for_name = name + curr_label = data.pop(CURRENT_LABEL) + if curr_label is not None: + # this key is set in LabelContainer, when present + # we can associate the label with the widget it is labelling + curr_label._xmlui_for_name = name else: raise NotImplementedError(_("Unknown tag [%s]") % node.nodeName)