Download

When adding child to canvas panel, game crashes

Commented bit causes crash.

	for (const UInventoryItem* ItemHere : InventoryLocal->Items)
	{
		
		UInventoryItem* Item = CreateWidget<UInventoryItem>(GetWorld(), InventoryItemClass);
		if (IsValid(Item) && Item != nullptr)
		{
			
			if (Character != nullptr)
			{
				Item->OwningCharacter = Character;
			}
			else
			{
				UE_LOG(LogTemp, Warning, TEXT("Ses"));
			}
			
			//if (!ensure(InventoryBox != nullptr)) return;
			//InventoryBox->AddChild(Item);
			UE_LOG(LogTemp, Warning, TEXT("Sos"));
		}
		else
		{
			UE_LOG(LogTemp, Warning, TEXT("Null"));
		}
		
	}
	
}

Item which is being attached.

cpp:

#include "InventoryItem.h"
#include "Components/Button.h"

#include "CharacterMain.h"

UInventoryItem::UInventoryItem(const FObjectInitializer& ObjectInitializer)
: UUserWidget(ObjectInitializer)
{
	ItemDisplayName = FText::FromString("Item");
	UseActionText = FText::FromString("Use");
	return;
}

bool UInventoryItem::Initialize()
{
	//if (!ensure(UseButton != nullptr)) return false;
	//UseButton->OnClicked.AddDynamic(this, &UInventoryItem::UseClick);
	return true;
}
void UInventoryItem::UseClick()
{
	Use(OwningCharacter);
	OnUse(OwningCharacter);
}

void UInventoryItem::Use(ACharacterMain* Character)
{
	if (Character != nullptr)
	{
		FString Sus = Character->GetName();
		UE_LOG(LogTemp, Warning, TEXT("Nazwa twojej mamy %s"), *Sus);
	}
}

header:

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "InventoryItem.generated.h"

class ACharacterMain;

UCLASS()
class NOSZKURNA_API UInventoryItem : public UUserWidget
{
	GENERATED_BODY()
public:
	UInventoryItem(const FObjectInitializer& ObjectInitializer);

	virtual class UWorld* GetWorld() const { return World; };

	UPROPERTY(Transient)
		class UWorld* World;

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
		class UTexture2D* ThumbnailDefault;
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
		FText UseActionText;
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
		FText ItemDisplayName;

	UPROPERTY()
		class UInventoryComponent* OwningInventory;

	UFUNCTION(BlueprintImplementableEvent)
		void OnUse(ACharacterMain* Character);
	class ACharacterMain* OwningCharacter = nullptr;
protected:
	virtual bool Initialize() override;

	virtual void Use(ACharacterMain* Character);
private:
	void UseClick();

	UPROPERTY(meta = (BindWidget))
		class UImage* Thumbnail;
	UPROPERTY(meta = (BindWidget))
		class UButton* UseButton;
	UPROPERTY(meta = (BindWidget))
};

Could you show me what am I doing wrong? It worked before I added UPROPERTY(meta = (BindWidget)) things.