Another attempt at controlling when IDO creation and property path tracking are enabled

#jira UE-197352
#rb Phillip.Kavan
#rnx

[CL 32095396 by devin doucette in ue5-main branch]
This commit is contained in:
devin doucette
2024-03-07 14:06:08 -05:00
parent d96cf7d475
commit 4fe5bee68b
2 changed files with 8 additions and 7 deletions
@@ -4650,11 +4650,13 @@ void FLinkerLoad::Preload( UObject* Object )
// Toggle support for IDOs
FUObjectSerializeContext* LoadContext = FUObjectThreadContext::Get().GetSerializeContext();
// Do not enable IDOs when impersonation is enabled as it implies we are deserializing an IDO
const bool bIDOEnabled = UE::IsInstanceDataObjectSupportEnabled(Object) && !LoadContext->bImpersonateProperties;
// This will add property path tracking and create a property bag to hold any property that does not match the current class schema
TGuardValue<bool> ScopedTrackSerializedPropertyPath(LoadContext->bTrackSerializedPropertyPath, bIDOEnabled);
TGuardValue<bool> ScopedSerializeUnknownProperty(LoadContext->bSerializeUnknownProperty, bIDOEnabled);
// Enable property path tracking when IDO support is enabled. Both property bags and IDO creation require the paths.
const bool bHasIDOSupport = UE::IsInstanceDataObjectSupportEnabled(Object);
TGuardValue<bool> ScopedTrackSerializedPropertyPath(LoadContext->bTrackSerializedPropertyPath, bHasIDOSupport);
// Enable creation of a property bag to hold any property that does not match the current class schema,
// except when impersonation is enabled because that implies we are deserializing an IDO.
const bool bCreateIDO = bHasIDOSupport && !LoadContext->bImpersonateProperties;
TGuardValue<bool> ScopedSerializeUnknownProperty(LoadContext->bSerializeUnknownProperty, bCreateIDO);
if (Object->HasAnyFlags(RF_ClassDefaultObject))
{
@@ -4779,7 +4781,7 @@ void FLinkerLoad::Preload( UObject* Object )
}
// Object has been deserialized, if IDO is enabled, generate it
if (bIDOEnabled)
if (bCreateIDO)
{
UE::FPropertyBagRepository::Get().CreateInstanceDataObject(Object);
}
@@ -297,7 +297,6 @@ void FPropertyBagRepository::CreateInstanceDataObjectUnsafe(const UObjectBase* O
// setup load context to mark properties the that were set by serialization
FUObjectSerializeContext* LoadContext = FUObjectThreadContext::Get().GetSerializeContext();
TGuardValue<bool> ScopedImpersonateProperties(LoadContext->bImpersonateProperties, true);
TGuardValue<bool> ScopedTrackSerializedPropertyPath(LoadContext->bTrackSerializedPropertyPath, true);
UObject* OwnerAsObject = (UObject*)Owner;
if (FLinkerLoad* Linker = OwnerAsObject->GetLinker())