Path: Improve compatibility between file versions
Verify enumerations on document reload, maintaining the existing value for the property.
This commit is contained in:
@@ -102,6 +102,9 @@ class ObjectSurface(PathOp.ObjectOp):
|
||||
if not hasattr(obj, nm):
|
||||
obj.addProperty(prtyp, nm, grp, tt)
|
||||
missing.append(nm)
|
||||
newPropMsg = translate('PathSurface', 'New property added: ') + nm + '. '
|
||||
newPropMsg += translate('PathSurface', 'Check its default value.')
|
||||
PathLog.warning(newPropMsg)
|
||||
|
||||
# Set enumeration lists for enumeration properties
|
||||
if len(missing) > 0:
|
||||
@@ -253,6 +256,20 @@ class ObjectSurface(PathOp.ObjectOp):
|
||||
else:
|
||||
obj.setEditorMode('ShowTempObjects', 0) # show
|
||||
|
||||
# Repopulate enumerations in case of changes
|
||||
ENUMS = self.propertyEnumerations()
|
||||
for n in ENUMS:
|
||||
restore = False
|
||||
if hasattr(obj, n):
|
||||
val = obj.getPropertyByName(n)
|
||||
restore = True
|
||||
cmdStr = 'obj.{}={}'.format(n, ENUMS[n])
|
||||
exec(cmdStr)
|
||||
if restore:
|
||||
cmdStr = 'obj.{}={}'.format(n, "'" + val + "'")
|
||||
exec(cmdStr)
|
||||
|
||||
|
||||
self.setEditorProperties(obj)
|
||||
|
||||
def opSetDefaultValues(self, obj, job):
|
||||
|
||||
Reference in New Issue
Block a user