Skip to content

Commit

Permalink
Validate MultipleSelect settings are arrays before applying in GUI.
Browse files Browse the repository at this point in the history
This prevents the GUI from silently setting MultipleSelects to value that isn't a collection in cases of old/broken setting saves and presets.

This reverts commit f06d58d, which is no longer necessary.
  • Loading branch information
Cuphat committed Apr 11, 2022
1 parent d51c913 commit e337d7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions GUI/src/app/providers/GUIGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ export class GUIGlobal {
this.verifyNumericSetting(settingsObj, setting, false);
this.generator_settingsMap[setting.name] = settingsObj[setting.name];
}
else if (setting.type == "MultipleSelect") { //Validate list types before applying them
if (Array.isArray(settingsObj[setting.name]))
this.generator_settingsMap[setting.name] = settingsObj[setting.name];
}
else { //Everything else
this.generator_settingsMap[setting.name] = settingsObj[setting.name];
}
Expand Down
4 changes: 0 additions & 4 deletions Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ def get_settings_string(self):
i_bits = [1 if digit=='1' else 0 for digit in bin(value)[2:]]
i_bits.reverse()
if setting.type == list:
if not isinstance(value, (list, tuple, set)):
# If the setting type is list but the value of the setting is not, use an empty list.
# TODO: Add sanity checks for 'MultipleSelect' in the GUI function 'applySettingsObject'.
value = []
if len(value) > len(setting.choice_list) / 2:
value = [item for item in setting.choice_list if item not in value]
terminal = [1] * setting.bitwidth
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '6.2.71 f.LUM'
__version__ = '6.2.72 f.LUM'

0 comments on commit e337d7f

Please sign in to comment.