[core] in case of CompatibilityNode the dynamic output attributes does not exist as they are not saved in the project

So we always check if they exist before accessing them.
This commit is contained in:
Fabien Castan 2024-06-16 18:56:38 +02:00
parent 77571dca38
commit 972d5751e1

View file

@ -1023,7 +1023,10 @@ class BaseNode(BaseObject):
# logging.warning("resetOutputAttr: {}".format(self.name))
for output in self.nodeDesc.outputs:
if output.isDynamicValue:
self.attribute(output.name).value = None
if self.hasAttribute(output.name):
self.attribute(output.name).value = None
else:
logging.warning(f"resetOutputAttr: Missing dynamic output attribute: {self.name}.{output.name}")
def loadOutputAttr(self):
""" Load output attributes with dynamic values from a values.json file.
@ -1042,7 +1045,10 @@ class BaseNode(BaseObject):
# logging.warning(data)
for output in self.nodeDesc.outputs:
if output.isDynamicValue:
self.attribute(output.name).value = data[output.name]
if self.hasAttribute(output.name):
self.attribute(output.name).value = data[output.name]
else:
logging.warning(f"loadOutputAttr: Missing dynamic output attribute: {self.name}.{output.name}")
def saveOutputAttr(self):
""" Save output attributes with dynamic values into a values.json file.
@ -1052,7 +1058,10 @@ class BaseNode(BaseObject):
data = {}
for output in self.nodeDesc.outputs:
if output.isDynamicValue:
data[output.name] = self.attribute(output.name).value
if self.hasAttribute(output.name):
data[output.name] = self.attribute(output.name).value
else:
logging.warning(f"saveOutputAttr: Missing dynamic output attribute: {self.name}.{output.name}")
valuesFile = self.valuesFile
# logging.warning("save output attr: {}, value: {}".format(self.name, valuesFile))