mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-02 00:08:29 +02:00
[core] copy attribute desc default value
to ensure that it is not editable if the value is a list
This commit is contained in:
parent
44d6b45c18
commit
7d99ba4b59
1 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding:utf-8
|
# coding:utf-8
|
||||||
import collections
|
import collections
|
||||||
|
import copy
|
||||||
import re
|
import re
|
||||||
import weakref
|
import weakref
|
||||||
import types
|
import types
|
||||||
|
@ -55,7 +56,7 @@ class Attribute(BaseObject):
|
||||||
self._node = weakref.ref(node)
|
self._node = weakref.ref(node)
|
||||||
self.attributeDesc = attributeDesc
|
self.attributeDesc = attributeDesc
|
||||||
self._isOutput = isOutput
|
self._isOutput = isOutput
|
||||||
self._value = attributeDesc.value
|
self._value = copy.copy(attributeDesc.value)
|
||||||
self._label = attributeDesc.label
|
self._label = attributeDesc.label
|
||||||
|
|
||||||
# invalidation value for output attributes
|
# invalidation value for output attributes
|
||||||
|
@ -204,7 +205,8 @@ class Attribute(BaseObject):
|
||||||
def defaultValue(self):
|
def defaultValue(self):
|
||||||
if isinstance(self.desc.value, types.FunctionType):
|
if isinstance(self.desc.value, types.FunctionType):
|
||||||
return self.desc.value(self)
|
return self.desc.value(self)
|
||||||
return self.desc.value
|
# Need to force a copy, for the case where the value is a list (avoid reference to the desc value)
|
||||||
|
return copy.copy(self.desc.value)
|
||||||
|
|
||||||
def _isDefault(self):
|
def _isDefault(self):
|
||||||
return self._value == self.defaultValue()
|
return self._value == self.defaultValue()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue