UE crash when button clicked

hi!
I make ui with HUD and SlateWidget

I want when i click on button event send to blueprint

I made all like in slate tutorial part 1
And when i click on button unreal crash.

Here my hud header


#pragma once

#include "GameFramework/HUD.h"
#include "VJHUD.generated.h"

UCLASS()
class VJ_API AVJHUD : public AHUD
{
	GENERATED_BODY()
	virtual void PostInitializeComponents() override;
	
	TSharedPtr<SWindow> SlateWin;

public:
	UFUNCTION(BlueprintImplementableEvent, Category = "VJ")
		void ButtonClicked();

	UFUNCTION(BlueprintImplementableEvent, Category = "VJ")
		void Button1Clicked();
};


here slate header


#pragma once

#include "Widgets/SCompoundWidget.h"
#include "VJHUD.h"

class VJ_API Svjui : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS(Svjui)
	{}
	SLATE_ARGUMENT(TWeakObjectPtr<class AVJHUD>, VJHUD)
	SLATE_END_ARGS()

	void Construct(const FArguments& InArgs);

	FReply ButtonClicked();
	FReply Button1Clicked();

	TWeakObjectPtr<class AVJHUD> VJHUD;
};


and slate cpp


#include "vj.h"
#include "Svjui.h"
#include "SlateOptMacros.h"

#define LOCTEXT_NAMESPACE "vjui"

BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void Svjui::Construct(const FArguments& InArgs)
{
	VJHUD = InArgs._VJHUD;

	ChildSlot
		.VAlign(VAlign_Fill)
		.HAlign(HAlign_Fill)
		
			SNew(SVerticalBox)
			+ SVerticalBox::Slot().HAlign(HAlign_Center)
		
			SNew(STextBlock)
			.ShadowColorAndOpacity(FLinearColor::Black)
		.ColorAndOpacity(FLinearColor::White)
		.ShadowOffset(FIntPoint(-1, 1))
		.Font(FSlateFontInfo("Veranda", 16))
		.Text(LOCTEXT("Title", "VJ controls!"))
		]
	+ SVerticalBox::Slot().HAlign(HAlign_Fill)
		
			SNew(SButton)
			.Text(LOCTEXT("button", "Button"))
			.OnClicked(this, &Svjui::ButtonClicked)

		]
	+ SVerticalBox::Slot().HAlign(HAlign_Fill)
		
			SNew(SButton)
			.Text(LOCTEXT("button1", "Button1"))
			.OnClicked(this, &Svjui::Button1Clicked)

		]
	+ SVerticalBox::Slot().HAlign(HAlign_Fill)
		
			SNew(SButton)
			.Text(LOCTEXT("button2", "Button2"))

		]

		];
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
FReply Svjui::ButtonClicked()
{
	/*
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Yellow, TEXT("0"));
	}
	*/
	VJHUD->ButtonClicked();
	return FReply::Handled();
}
FReply Svjui::Button1Clicked()
{
	/*if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Yellow, TEXT("1"));
	}
	*/
	VJHUD->Button1Clicked();
	return FReply::Handled();
}
#undef LOCTEXT_NAMESPACE


And crash log


LoginId:e918ef2449fb1aaae7171aabe0c65362
EpicAccountId:e400886435fe445f82d0d3d16e225617

Access violation - code c0000005 (first/second chance not available)

UE4Editor_CoreUObject
UE4Editor_vj_1516!AVJHUD::ButtonClicked()
UE4Editor_vj_1516!Svjui::ButtonClicked() [c:\users
oobusdeer\yandexdisk\myproj\unreal\vj\source\vj\svjui.cpp:59]
UE4Editor_vj_1516!TMemberFunctionCaller<Svjui,FReply (__cdecl Svjui::*)(void) __ptr64>::operator()<>() [c:\program files\epic games\ue_4.15\engine\source\runtime\core\public\delegates\delegateinstanceinterface.h:165]
UE4Editor_vj_1516!TTupleImpl<TIntegerSequence<unsigned int> >::ApplyAfter<TMemberFunctionCaller<Svjui,FReply (__cdecl Svjui::*)(void) __ptr64> >() [c:\program files\epic games\ue_4.15\engine\source\runtime\core\public\delegates	uple.h:134]
UE4Editor_vj_1516!TBaseSPMethodDelegateInstance<0,Svjui,0,FReply __cdecl(void)>::Execute() [c:\program files\epic games\ue_4.15\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:327]
UE4Editor_Slate
UE4Editor_Slate
UE4Editor_Slate
UE4Editor_Slate
UE4Editor_Slate
UE4Editor_Slate
UE4Editor_Slate
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
user32
user32
UE4Editor_Core
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll

UE version 4.15.1

The exception you are getting (0xC0000005) means that you are accessing a null pointer.

I don’t see any problems, But the formating is not what I am used to tho.

HTH

Thanks!

Yeah you right

Variable VJHUD is null but do you know why?

this header


#pragma once

#include "Widgets/SCompoundWidget.h"
#include "VJHUD.h"

class VJ_API Svjui : public SCompoundWidget
{

	SLATE_BEGIN_ARGS(Svjui)
	{
	}
	SLATE_ARGUMENT(TWeakObjectPtr<class AVJHUD>, VJHUD)
	SLATE_END_ARGS()

	FReply ButtonClicked();
	FReply Button1Clicked();

	TWeakObjectPtr<class AVJHUD> VJHUD;
public:
	void Construct(const FArguments& InArgs);
};


beginning of cpp


#include "vj.h"
#include "Svjui.h"

#define LOCTEXT_NAMESPACE "vjui"

BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION

void Svjui::Construct(const FArguments& InArgs)
{
	VJHUD = InArgs._VJHUD;
	if (VJHUD == NULL) {
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Yellow, TEXT("NULL"));
		}
	}

Did you define(create) the “FArguments” type? (Did UE create that by default, I do not recall seing a type like that in my (small) project)

I assume that the “InArgs._VJHUD” is also null, Where does that come from?

I would use “VJHUD.IsValid()” checks and print a message to the log and possible the screen if it is not set.

HTH