mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-20 20:46:28 +02:00
[graph] ListAttribute: replace '__getitem__ by 'at'
__getitem__ is spuriously called when the object is used inside a Qt model and exposed to QML, leading to unexpected behaviors
This commit is contained in:
parent
a5cda66670
commit
2cd724f957
4 changed files with 25 additions and 22 deletions
|
@ -285,12 +285,15 @@ class ListAttribute(Attribute):
|
|||
super(ListAttribute, self).__init__(node, attributeDesc, isOutput, root, parent)
|
||||
self._value = ListModel(parent=self)
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self._value.at(item)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._value)
|
||||
|
||||
def at(self, idx):
|
||||
""" Returns child attribute at index 'idx' """
|
||||
# implement 'at' rather than '__getitem__'
|
||||
# since the later is called spuriously when object is used in QML
|
||||
return self._value.at(idx)
|
||||
|
||||
def _set_value(self, value):
|
||||
self.desc.validateValue(value)
|
||||
self._value.clear()
|
||||
|
@ -317,7 +320,7 @@ class ListAttribute(Attribute):
|
|||
def remove(self, index, count=1):
|
||||
if self.node.graph:
|
||||
for i in range(index, index + count):
|
||||
attr = self[i]
|
||||
attr = self._value.at(i)
|
||||
if attr.isLink:
|
||||
self.node.graph.removeEdge(attr) # delete edge if the attribute is linked
|
||||
self._value.removeAt(index, count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue