BindWidget, OptionalWidget and class mismatches

Hey benhumphreys-

Can you elaborate on what you’re doing in step 4? After creating the blueprint and adding something to it (button, canvas Panel, border, etc), any attempt to change the name to “MyContainer” will revert to the previous name. This happened when trying to rename it from the details panel or directly from the Hierarchy.

  1. Created blueprint based on UserWidget
  2. Add button
  3. Change button name to MyContainer
  4. Reparent blueprint to CrashTestWidget

At this point the blueprint had a compile error due to the name conflict and as a result would not successfully compile. Changing the name of my button produced the results I mentioned previously. If you’re able to reproduce the crash locally, could you provide a small sample project that demonstrates the crash?

  1. Create a C++ subclass of UUserWidget, let’s call it UCrashTestWidget
  2. Add a property marked UPROPERTY(meta=(BindWidget, OptionalWidget=true)), with type UOverlay (or anything). Give it name MyContainer
  3. In the Unreal editor, create a Blueprint subclass of UCrashTestWidget
  4. Inside the widget, create a widget that is not a UOverlay, but call it "MyContainer"
  5. Run the game. Notice: MyContainer is not null but it is not initialized correctly.

This seems like a dumb error, but I spent 20 mins wondering why today. I had another widget in my hierarchy named the wrong thing, and was getting a crash in C++ because of badly-initialized classes.

I would expect an error (or at least a warning) if the widget in my Blueprint does not match the expected BindWidget type.

Sorry the exact behaviour I did was:

  1. While the UMG Widget Blueprint class is a sublcass of UUserWidget, create a widget that is not an UOverlay, called MyContainer.
  2. Reparent UMG Widget Blueprint to UCrashTestWidget
  3. Run game, notice that MyContainer is not-null, but not a valid UOverlay (as expected, it was initialized from another type of widget).

I assumed the same thing would happen if I created the widget from scratch, but actually the wrongly-typed (and conlictingly-named widget) already existed, when I reparented the widget…

I realise it’s quite a niche bug, now.

Hey benhumphreys-

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

Cheers