Hi Rudy. I’m using 4.7.6.
To reproduce simply do the following:
-
Add a new c++ class deriving from UUserWidget, as follows:
// TestUserWidget.h
#pragma once#include “Blueprint/UserWidget.h”
#include “TestUserWidget.generated.h”UCLASS()
class AWARENESSDEMO_API UTestUserWidget : public UUserWidget
{
GENERATED_BODY()public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UButton* TestButtonProp;virtual void Construct_Implementation() override; UFUNCTION() void OnClicked();
};
// TestUserWidget.cpp
#include “ProjectPCH.h”
#include “TestUserWidget.h”
#include “Components/PanelWidget.h”
#include “Components/ContentWidget.h”
#include “Components/Button.h”void UTestUserWidget::Construct_Implementation()
{
TestButtonProp->OnClicked.AddDynamic(this, &UTestUserWidget::OnClicked);
}void UTestUserWidget::OnClicked()
{}
-
In the editor, add a new Widget Blueprint, and reparent it to the above class.
-
Drop a button (named TestButton) in the designer, then configure the event graph as shown.
- In level blueprint BeginPlay (or anywhere really) create an instance of the widget, and immediately call in succession: AddToViewport → Remove → Add.
Note that I can easily find ways to work around the resulting crash, but I’d just like to know what it is about the process that is incorrect usage. Specifically, it seems counter intuitive to me that the parent user widget could get reconstructed while its child components persist.
Cheers.