Widget Switcher Array Index Crash [Repro]

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:

  1. Create a new UMG User Widget in the Content Browser and add a ‘Widget Switcher’ item to it.
  2. Add three children to the widget switcher (doesn’t matter what they are).
  3. Select the Widget Switcher and set the ‘Active Widget Index’ to ‘2’
  4. Now drag-and-drop the last child of the Widget switcher to another widget, or delete it entirely.
  5. Select the first child again. (if you skip this step, the crash won’t occur).
  6. 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.

Hello ,

After doing a big of digging I found that this is a known issue (UE-19741) and it has been resolved internally. I have provided a link to the commit below. If you are working from source you could cherry pick this solution and pull it down into your project. I hope that this information helps.

Link to commit: https://github.com/EpicGames/UnrealEngine/commit/d304f9cb9d58b4037e39cf22a486c209ffd4d036

Make it a great day

Great stuff, thanks Rudy!