[core] invalidate= becomes optional and is set to True by default

This will allow to simplify node descriptions as most of the attributes
are generally invalidating. Only non-invalidating attributes will need
to state explicitly `invalidate=False`.

For output attributes, which must not be invalidating, `invalidate` will
be automatically set to `False` at the attribute-level if it is set to
`True` in the description.
This commit is contained in:
Candice Bentéjac 2024-09-06 15:11:39 +02:00
parent 41e885d9ff
commit b981ef651c
3 changed files with 53 additions and 54 deletions

View file

@ -59,6 +59,7 @@ class Attribute(BaseObject):
self._enabled = True
self._validValue = True
self._description = attributeDesc.description
self._invalidate = False if self._isOutput else attributeDesc.invalidate
# invalidation value for output attributes
self._invalidationValue = ""
@ -448,6 +449,7 @@ class Attribute(BaseObject):
node = Property(BaseObject, node.fget, constant=True)
enabledChanged = Signal()
enabled = Property(bool, getEnabled, setEnabled, notify=enabledChanged)
invalidate = Property(bool, lambda self: self._invalidate, constant=True)
uidIgnoreValue = Property(Variant, getUidIgnoreValue, constant=True)
validValueChanged = Signal()
validValue = Property(bool, getValidValue, setValidValue, notify=validValueChanged)
@ -619,7 +621,7 @@ class ListAttribute(Attribute):
if isinstance(self.value, ListModel):
uids = []
for value in self.value:
if value.desc.invalidate:
if value.invalidate:
uids.append(value.uid())
return hashValue(uids)
return super(ListAttribute, self).uid()
@ -755,7 +757,7 @@ class GroupAttribute(Attribute):
def uid(self):
uids = []
for k, v in self._value.items():
if v.enabled and v.desc.invalidate:
if v.enabled and v.invalidate:
uids.append(v.uid())
return hashValue(uids)