Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
Bugfix/unr 1729 check for unloaded class in metadata (#1189)
Browse files Browse the repository at this point in the history
* Use weak pointer in UnrealMetadata

* Add log for stale classes
  • Loading branch information
m-samiec authored Jul 21, 2019
1 parent 2b97896 commit fd574a0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions SpatialGDK/Source/SpatialGDK/Public/Schema/UnrealMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,18 @@ struct UnrealMetadata : Component

FORCEINLINE UClass* GetNativeEntityClass()
{
if (NativeClass != nullptr)
if (NativeClass.IsValid())
{
return NativeClass;
return NativeClass.Get();
}

#if !UE_BUILD_SHIPPING
if (NativeClass.IsStale())
{
UE_LOG(LogSpatialClassInfoManager, Warning, TEXT("UnrealMetadata native class %s unloaded whilst entity in view."), *ClassPath);
}
#endif

if (UClass* Class = LoadObject<UClass>(nullptr, *ClassPath))
{
if (Class->IsChildOf<AActor>())
Expand All @@ -90,7 +97,7 @@ struct UnrealMetadata : Component
FString ClassPath;
TSchemaOption<bool> bNetStartup;

UClass* NativeClass = nullptr;
TWeakObjectPtr<UClass> NativeClass;
};

FORCEINLINE SubobjectToOffsetMap CreateOffsetMapFromActor(AActor* Actor, const FClassInfo& Info)
Expand Down

0 comments on commit fd574a0

Please sign in to comment.