FIX: out of range exception when pressing undo after creating and editing a new control scheme (ISXB-1607) by Darren-Kelly-Unity · Pull Request #2237 · Unity-Technologies/InputSystem · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed the compilation warnings when used with Unity 6.4 (ISX-2349).
- Fixed an issue where `InputSystemUIInputModule.localMultiPlayerRoot` could not be set to `null` when using `MultiplayerEventSystem`. [ISXB-1610](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1610)
- Fixed an issue in `Keyboard` where the sub-script operator would return a `null` key control for the deprecated key `Key.IMESelected`. Now, an aliased `KeyControl`mapping to the IMESelected bit is returned for compability reasons. It is still strongly advised to not rely on this key since `IMESelected` bit isn't strictly a key and will be removed from the `Key` enumeration type in a future major revision. [ISXB-1541](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1541).
- Fixed an ArgumentOutOfRangeException that was thrown when pressing the undo shortcut while changing a control scheme name. [ISXB-1607](https://issuetracker.unity3d.com/issues/argumentoutofrangeexception-error-is-thrown-when-pressing-the-undo-shortcut-while-changing-the-control-scheme-name)
- Fixed an issue where the onAnyButtonPress callback would be triggered multiple times during unrelated events when a button is held down. See [ISXB-1005](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1005).
- Fixed InputControl picker not updating correctly when the Input Actions Window was dirty. [ISXB-1221](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1221)
- Fixed formatting issues on processor documentation page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,16 @@
{
return (in InputActionsEditorState state) =>
{
var controlSchemeSerializedProperty = state.selectedControlSchemeIndex == -1 ? null :
state.serializedObject
.FindProperty(nameof(InputActionAsset.m_ControlSchemes))
.GetArrayElementAtIndex(state.selectedControlSchemeIndex);
SerializedProperty controlSchemeSerializedProperty = null;
var serializedProperty = state.serializedObject

Check warning on line 149 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs#L148-L149

Added lines #L148 - L149 were not covered by tests
.FindProperty(nameof(InputActionAsset.m_ControlSchemes));

if (state.selectedControlSchemeIndex < serializedProperty.arraySize)
{
controlSchemeSerializedProperty = state.selectedControlSchemeIndex == -1 ? null :

Check warning on line 154 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs#L152-L154

Added lines #L152 - L154 were not covered by tests
serializedProperty
.GetArrayElementAtIndex(state.selectedControlSchemeIndex);
}

Check warning on line 157 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs#L157

Added line #L157 was not covered by tests

if (controlSchemeSerializedProperty == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ private void RemoveDeviceRequirement()
public override void RedrawUI(InputControlScheme viewState)
{
rootElement.Q<TextField>(kControlSchemeNameTextField).value = string.IsNullOrEmpty(m_NewName) ? viewState.name : m_NewName;

m_ListView.itemsSource?.Clear();
m_ListView.itemsSource = viewState.deviceRequirements.Count > 0 ?
viewState.deviceRequirements.Select(r => (r.controlPath, r.isOptional)).ToList() :
Expand All @@ -128,7 +127,7 @@ private void SaveAndClose()
CloseView();
}

private void Cancel()
internal void Cancel()
{
// Reload the selected ControlScheme values from the SerilaizedProperty and throw away any changes
Dispatch(ControlSchemeCommands.ResetSelectedControlScheme());
Expand Down