Description

This is an issue with how FPropertyValueImpl::ResetToDefault works: it uses GetDefaultValueAsString to reset the default value. This is problematic because the LexToString function that is eventually called uses a format specifier of "%f", which defaults to a precision of six.

In the above example, 0.15 + 0.3 is actually 0.449999988079071044922, but LexToString converts to 0.450000, which is what we set the component's value to. As a result, diffs with the CDO's value will always fail.

Steps to Reproduce

To reproduce this issue, create an actor component in C++ and add a property like this:

UPROPERTY(EditAnywhere)

double MyTestDouble = 0.15 + 0.3; 

* Create an Actor Blueprint
  • Add the component with the property to the blueprint
  • Change the value of `MyTestDouble` in the blueprint to `1.0`
  • Press the "Reset to Default" arrow
  • Notice that the value is still considered overwritten after resetting to default, and the "Reset to Default" arrow continues to be present forever

The second step is even more scary, because it will cause bad property values for actors in the level:

  • Create a new Actor blueprint (do not use the same one as before, since changing `MyTestDouble` has broken that one)
  • Add the component with the property to the blueprint
  • Drag out an instance of the blueprint actor into a level, notice that its value for `MyTestDouble` will show as a defaulted `0.45`
  • Notice that the value for `MyTestDouble` in the blueprint shows as a defaulted `0.45`
  • Change the value for `MyTestDouble` in the blueprint to `1.0`
  • Notice that the value for `MyTestDouble` for the actor instance in the level is still incorrectly `0.45`, and was not updated even though it was defaulted

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-149061 in the post.

4
Login to Vote

Backlogged
ComponentUE - Gameplay - LWC
Affects Versions5.0
CreatedApr 13, 2022
UpdatedJan 22, 2024