If you delete a widget from a Widget Switcher in UMG, but the ‘Active Widget Index’ is assigned to the last Widget, you’ll get an Array Access Violation and a crash.
This is easy to reproduce:
- Create a new UMG User Widget in the Content Browser and add a ‘Widget Switcher’ item to it.
- Add three children to the widget switcher (doesn’t matter what they are).
- Select the Widget Switcher and set the ‘Active Widget Index’ to ‘2’
- Now drag-and-drop the last child of the Widget switcher to another widget, or delete it entirely.
- Select the first child again. (if you skip this step, the crash won’t occur).
- Try to select the Widget switcher. You should get an instant crash.
This is caused by the ‘Active Widget Index’ still being set to ‘2’ - even though child 2 no longer exists but the Array of children has already been resized. Forcing the Active Widget Index value to 0 when a child is deleted would easily fix this issue.