MVVM: Always assign the viewmodel value to the property value. It's a bug to not assign it when it's null.

#rb daren.cheng

[CL 31587293 by patrick boutot in ue5-main branch]
This commit is contained in:
patrick boutot
2024-02-16 18:52:47 -05:00
parent 7b43f29a2d
commit 16e9296b30

View File

@@ -173,25 +173,26 @@ void UMVVMView::InitializeSourceInternal(UObject* NewSource, FMVVMViewClass_Sour
if (NewSource)
{
ValidSources |= SourceKey.GetBit();
if (ClassSource.RequireSettingUserWidgetProperty())
{
UUserWidget* UserWidget = GetUserWidget();
FObjectPropertyBase* FoundObjectProperty = FindFProperty<FObjectPropertyBase>(UserWidget->GetClass(), ClassSource.GetUserWidgetPropertyName());
if (ensureAlwaysMsgf(FoundObjectProperty, TEXT("The compiler should have added the property")))
{
if (ensure(NewSource->GetClass()->IsChildOf(FoundObjectProperty->PropertyClass)))
{
FoundObjectProperty->SetObjectPropertyValue_InContainer(UserWidget, NewSource);
ViewSource.bAssignedToUserWidgetProperty = true;
}
}
}
}
else
{
ValidSources &= ~SourceKey.GetBit();
}
if (ClassSource.RequireSettingUserWidgetProperty())
{
UUserWidget* UserWidget = GetUserWidget();
FObjectPropertyBase* FoundObjectProperty = FindFProperty<FObjectPropertyBase>(UserWidget->GetClass(), ClassSource.GetUserWidgetPropertyName());
if (ensureAlwaysMsgf(FoundObjectProperty, TEXT("The compiler should have added the property")))
{
if (NewSource == nullptr || ensure(NewSource->GetClass()->IsChildOf(FoundObjectProperty->PropertyClass)))
{
FoundObjectProperty->SetObjectPropertyValue_InContainer(UserWidget, NewSource);
ViewSource.bAssignedToUserWidgetProperty = true;
}
}
}
ViewSource.Source = NewSource;
}