mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Don't add a setting if evaluation failed
If the eval failed that is likely caused by a variable not existing. It now continues with evaluating other settings and just doesn't add the setting that depends on non-existing legacy settings. This happens when the imported profile is not complete or corrupt. Contributes to issue CURA-37.
This commit is contained in:
parent
7f1a746a45
commit
9feb609fba
1 changed files with 6 additions and 3 deletions
|
@ -96,8 +96,11 @@ class LegacyProfileReader(ProfileReader):
|
|||
for new_setting in dict_of_doom["translation"]: #Evaluate all new settings that would get a value from the translations.
|
||||
old_setting_expression = dict_of_doom["translation"][new_setting]
|
||||
compiled = compile(old_setting_expression, new_setting, "eval")
|
||||
try:
|
||||
new_value = eval(compiled, {"math": math}, legacy_settings) #Pass the legacy settings as local variables to allow access to in the evaluation.
|
||||
if profile.getSettingValue(new_setting) != new_value: #Not equal to the default.
|
||||
profile.setSettingValue(new_setting, new_value) #Store the setting in the profile!
|
||||
except Exception as e: #Probably some setting name that was missing or something else that went wrong in the ini file.
|
||||
Logger.log("w", "Setting " + new_setting + " could not be set because the evaluation failed. Something is probably missing from the imported legacy profile.")
|
||||
|
||||
return profile
|
Loading…
Add table
Add a link
Reference in a new issue