Superfluous nullptr check?

I saw the following code in PaperSprite.cpp

Maybe I am totally missing something, but how can the check (BodySetup == nullptr) ever fail?

I know it is a GC system, but I don’t even see a reason to first set it to nullptr… NewObject sets the value anyways.

I ask this mostly to see whether my understanding of the GC is correct :slight_smile:

void UPaperSprite::RebuildCollisionData()
{
	UBodySetup* OldBodySetup = BodySetup;

	// Ensure we have the data structure for the desired collision method
	switch (SpriteCollisionDomain)
	{
	case ESpriteCollisionMode::Use3DPhysics:
		BodySetup = nullptr;
		if (BodySetup == nullptr)
		{
			BodySetup = NewObject<UBodySetup>(this);
		}
		break;

I believe you’re right.

Checking git log. commit 775efd976321dc2f66fc0f87f9eed65c7c3e9439

BodySetup3D and BodySetup2D is replaced by BodySetup, but the checking is not handled properly

137203-2017-05-08+18_04_37-unrealengine_+--all+-+gitk.png