Multi versions of Unreal Crash when I try to open my project

Hello,

I am on Section 3 Lesson 71. After I add the new AActor Component OpenDoor the engine crashes. I am using Unreal 4.19.2 and Microsoft Visual C++ 2017. I have started the project over from scratch twice now with the same results. I included the log file from BuildingEscape/Saved/Logs and these 4 files Opendoor.h, .cpp, PositionReport.cpp, .h in BuildingEscape.zip.

I felt like I was making good progress but this issue has kicked my butt the last 2 evenings and Sunday. Any help is greatly appreciated.

Thank you, MikeW

BuildingEscape.zip (2.6 KB)

BuildingEscape-backup-2019.02.12-18.35.54.log.zip (6.6 KB)

Because you’re calling code in the constructor that would return nullptr

UOpenDoor::UOpenDoor()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// Find the owning actor
    //////////////////////////////////////////
	FString ObjectName = GetOwner()->GetName();
	FString ObjectPos = GetOwner()->GetTransform().GetLocation().ToString();
    ///////////////////////////////////////////
	UE_LOG(LogTemp, Warning, TEXT("%s is at %s"), *ObjectName, *ObjectPos);
}

The code within the //'s is problematic. GetOwner() would return nullptr in the constructor as the component doesn’t have an owner at that stage and you are then dereferencing the by using ->. Dereferencing a nullptr is undefined behaviour and causes Unreal to crash.

Only the first line should be in the constructor.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms