From a65163df27d134cb164fe9a11870c5d547b8fd54 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 14 Jul 2020 16:56:00 -0400 Subject: [PATCH] Window.getState: return default if prop not in obj If the requested object in states.json exists but doesn't contain the property we're looking for, return the default value (passed to the function) instead of undefined. --- src/gui/Window.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/Window.qml b/src/gui/Window.qml index f3022f25..417072c4 100644 --- a/src/gui/Window.qml +++ b/src/gui/Window.qml @@ -52,7 +52,8 @@ ApplicationWindow { function getState(obj, property, defaultValue=undefined) { try { - return uiState[obj.saveName][obj.saveId || "ALL"][property] + const props = uiState[obj.saveName][obj.saveId || "ALL"] + return property in props ? props[property] : defaultValue } catch(err) { return defaultValue }