Fix crash where dict may not contain settings id key. Common occurence if restore platform differs from backup platform. (#212)

This commit is contained in:
finlay-mcaree 2022-06-14 07:14:23 -07:00 committed by GitHub
parent c951dce5bd
commit 6294b5ce74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,10 +33,12 @@ class GuiSettingsManager:
restoreCount = 0 restoreCount = 0
for aSetting in restoreSettings: for aSetting in restoreSettings:
# Ensure key exists before referencing
if(aSetting['id'] in settingsDict.values()):
# only update a setting if its different than the current (action types have no value) # only update a setting if its different than the current (action types have no value)
if(aSetting['type'] != 'action' and settingsDict[aSetting['id']] != aSetting['value']): if(aSetting['type'] != 'action' and settingsDict[aSetting['id']] != aSetting['value']):
if(utils.getSettingBool('verbose_logging')): if(utils.getSettingBool('verbose_logging')):
utils.log('%s different than current: %s' % (aSetting['id'], str(aSetting['value']))) utils.log('%s different than current: %s' % (aSetting['id'], str(aSetting['value'])))
updateJson['params']['setting'] = aSetting['id'] updateJson['params']['setting'] = aSetting['id']
updateJson['params']['value'] = aSetting['value'] updateJson['params']['value'] = aSetting['value']