(Solved) Passing if (Subsystem != nullptr) with NULL

Edit: Apparently in UE 4.24.3 the NULL subsystem is put in place by default.

IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get();
if(Subsystem != nullptr)
	{
		UE_LOG(LogTemp, Warning, TEXT("Game Instance Init found subsystem %s"), *Subsystem->GetSubsystemName().ToString());
	}
	else
	{
		UE_LOG(LogTemp, Warning, TEXT("Game Instance Init did not find a subsystem"));
	}

That is printing out Game Instance Init found subsystem NULL
Changing it to if(Subsystem){} else {} is still evaluating to true.

2 Likes

Found the same in 4.25.1.

On a side note, I also do my checks with

if (Subsystem) 
{ 
      run code;
}

or

if (!Subsystem) { return; } 

Learned this technique from another Gamedev.tv tutorial series for C++. Easier IMO than the !ensure stuff and != nullptr checks.

Privacy & Terms