From 6294b5ce749bf2f80f61f859663ecee09d97549d Mon Sep 17 00:00:00 2001 From: finlay-mcaree <13505775+finlay-mcaree@users.noreply.github.com> Date: Tue, 14 Jun 2022 07:14:23 -0700 Subject: [PATCH] Fix crash where dict may not contain settings id key. Common occurence if restore platform differs from backup platform. (#212) --- resources/lib/guisettings.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/lib/guisettings.py b/resources/lib/guisettings.py index 50a4666..8fe3def 100644 --- a/resources/lib/guisettings.py +++ b/resources/lib/guisettings.py @@ -33,10 +33,12 @@ class GuiSettingsManager: restoreCount = 0 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) - if(aSetting['type'] != 'action' and settingsDict[aSetting['id']] != aSetting['value']): - if(utils.getSettingBool('verbose_logging')): - utils.log('%s different than current: %s' % (aSetting['id'], str(aSetting['value']))) + if(aSetting['type'] != 'action' and settingsDict[aSetting['id']] != aSetting['value']): + if(utils.getSettingBool('verbose_logging')): + utils.log('%s different than current: %s' % (aSetting['id'], str(aSetting['value']))) updateJson['params']['setting'] = aSetting['id'] updateJson['params']['value'] = aSetting['value']