# \[UE5.1, Bug Report\] UUserWidgetExtension missing initalization.

**URL:** <https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667>\
**Category:** Issues and Bug Reporting\
**Tags:** unreal-engine, bug-report, editor, Widget, CPP, question, UMG\
**Created:** [February 23, 2023, 12:00am UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667 "2023-02-23T00:00:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 23, 2023, 12:00am UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667/1 "2023-02-23T00:00:00Z")

</div>

UUserWidgetExtension is supposed to be initialized by the UUserWidget.  
It can be initalized by it during two methods:

1. UUserWidget::AddExtension.
2. UUserWidget::NativeOnInitialized.

However, there is a situation in which an extension is never initialized.

```auto
void UYourWidget::NativeOnInitialized() {
	Super::NativeOnInitialized();
	
	UYourExtension* Ext = AddExtension<UYourExtension>();
}

```

UUserWidget::NativeOnInitialized does not initalize the extention because it has not been added yet. UUserWidget::AddExtension does not initialize the extention because bInitialized is set after NativeOnInitialized has completed. Broken! Adding the extension before call to Super::NativeOnInitialized smells.

---

<div class="post-metadata">

**Author:** ![pladux](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pladux/32/1194519_2.png) [@pladux](https://forums.unrealengine.com/u/pladux)\
**Post date:** [February 23, 2023, 7:43pm UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667/2 "2023-02-23T19:43:13Z")

</div>

As a workaround the UUserWidgetExtension::Construct method is called when the extension is added from within UUserWidget::NativeInitialze.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 23, 2023, 9:39pm UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667/3 "2023-02-23T21:39:27Z")

</div>

I think you misread the post. It is not about Construct but UUserWidgetExtension::Initialize, which is not called in the above situation. A workaround is this:

```auto
void UYourUserWidget::NativeOnInitialized() {
	UYourExtention* Ext = AddExtension<UYourExtention>();
	
	// Super
	Super::NativeOnInitialized();
}

```

which stinks.

---

<div class="post-metadata">

**Author:** ![pladux](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pladux/32/1194519_2.png) [@pladux](https://forums.unrealengine.com/u/pladux)\
**Post date:** [February 23, 2023, 9:54pm UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667/4 "2023-02-23T21:54:04Z")

</div>

No no, I think I got what you meant.

```auto
void UYourWidget::NativeOnInitialized() {
	Super::NativeOnInitialized();
	
	UYourExtension* Ext = AddExtension<UYourExtension>(); // <-- UYourExtension::Construct() is called here
}

```

So I did my initialization in UYourExtension::Construct(). But that’s much worse than your workaround. Thanks for pointing that out, I had somehow missed that at the time.

But to be honest, I also still didn’t fully understand the difference between the Construct and Initialize events for widgets yet 😉

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 23, 2023, 10:29pm UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667/5 "2023-02-23T22:29:38Z")

</div>

> [@pladux](#):
>
> `<-- UYourExtension::Construct() is called here`

Construct is not called there. The Construct method is not the same as the constructor. Different concepts. In the widgets Construct and Initialize have again very different meanings.

It’s ok I wasn’t looking for an answer this post is a bug report 🙂 . I draw some attention to issues on the forums cause if I write a report on the bug tracker for every thing I find I’ll be 80 before I’m done.

---

<div class="post-metadata">

**Author:** ![pladux](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pladux/32/1194519_2.png) [@pladux](https://forums.unrealengine.com/u/pladux)\
**Post date:** [February 23, 2023, 10:48pm UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667/6 "2023-02-23T22:48:49Z")

</div>

AddExtension calls both, the extensions Initialize() and its Construct() method. It also does that in this exact order which is not what I would expect.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 23, 2023, 10:58pm UTC](https://forums.unrealengine.com/t/ue5-1-bug-report-uuserwidgetextension-missing-initalization/776667/7 "2023-02-23T22:58:33Z")

</div>

> [@pladux](#):
>
> AddExtension calls both, the extensions Initialize() and its Construct() method. I

.

> [@Roy\_Wierer.Seda145](#):
>
> UUserWidget::AddExtension does not initialize the extention because bInitialized is set after NativeOnInitialized has completed.
