[core] Propagate Attribute.valueChanged to the owning Node through a Slot

Connecting the valueChanged signal to a lambda causes performance
issues with a large number of attributes when using the Pyside backend.
Connecting that signal to an intermediate Slot part of the Attribute class
improves performance dramatically.
Note: This has no comparable impact on the standalone backend.
This commit is contained in:
Yann Lanthony 2025-02-05 11:54:49 +01:00
parent 910736b3d7
commit 37a813e08a

View file

@ -31,7 +31,12 @@ def attributeFactory(description, value, isOutput, node, root=None, parent=None)
else:
attr.resetToDefaultValue()
attr.valueChanged.connect(lambda attr=attr: node._onAttributeChanged(attr))
# Only connect slot that reacts to value change once initial value has been set.
# NOTE: This should be handled by the Node class, but we're currently limited by our core
# signal implementation that does not support emitting parameters.
# And using a lambda here to send the attribute as a parameter causes
# performance issues when using the pyside backend.
attr.valueChanged.connect(attr._onValueChanged)
return attr
@ -213,6 +218,10 @@ class Attribute(BaseObject):
self.valueChanged.emit()
self.validValueChanged.emit()
@Slot()
def _onValueChanged(self):
self.node._onAttributeChanged(self)
def _set_label(self, label):
if self._label == label:
return