From 94abb8cc80b8e34bf3b30a81dbb96aa44dfe855b Mon Sep 17 00:00:00 2001 From: Eric M Date: Wed, 5 May 2021 11:33:08 +1000 Subject: [PATCH] Fixed crash in Editor Settings shortcuts UI --- editor/settings_config_dialog.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 81af4996ed1..541ec224b90 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -270,16 +270,17 @@ void EditorSettingsDialog::_update_shortcuts() { Array events; // Need to get the list of events into an array so it can be set as metadata on the item. Vector event_strings; - List> defaults = InputMap::get_singleton()->get_builtins().find(action_name).value(); - // Remove all non-key events from the defaults. - for (List>::Element *I = defaults.front(); I; I = I->next()) { + List> all_default_events = InputMap::get_singleton()->get_builtins().find(action_name).value(); + List> key_default_events; + // Remove all non-key events from the defaults. Only check keys, since we are in the editor. + for (List>::Element *I = all_default_events.front(); I; I = I->next()) { Ref k = I->get(); - if (k.is_null()) { - I->erase(); + if (k.is_valid()) { + key_default_events.push_back(k); } } - bool same_as_defaults = defaults.size() == action.inputs.size(); // Initially this is set to just whether the arrays are equal. Later we check the events if needed. + bool same_as_defaults = key_default_events.size() == action.inputs.size(); // Initially this is set to just whether the arrays are equal. Later we check the events if needed. int count = 0; for (List>::Element *I = action.inputs.front(); I; I = I->next()) { @@ -288,12 +289,8 @@ void EditorSettingsDialog::_update_shortcuts() { event_strings.push_back(I->get()->as_text()); // Only check if the events have been the same so far - once one fails, we don't need to check any more. - if (same_as_defaults) { - Ref k = defaults[count]; - // Only check keys, since we are in the editor. - if (k.is_valid() && !defaults[count]->shortcut_match(I->get())) { - same_as_defaults = false; - } + if (same_as_defaults && !key_default_events[count]->shortcut_match(I->get())) { + same_as_defaults = false; } count++; }