Path: Improve compatibility between file versions

Verify enumerations on document reload, maintaining the existing value for the property.
This commit is contained in:
Russell Johnson
2020-04-14 00:25:36 -05:00
parent 8e58f10f7f
commit b0a73d1266

View File

@@ -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):