When edited through the Details Panel in the Editor, TMap and TSet properties should not allow duplicate keys. When those keys are USTRUCTs with the “WithIdenticalViaEquality” trait, this should be ensured by comparing the keys with the struct’s == operator.

This does work in the check that does not allow a new item to be added when there is already one with the default key. But it does not work when setting fields in the key USTRUCT by typing in the details panel. In this case, it is possible to change the keys of several items to be the same. And this results in duplicate-key items being lost when saving and reloading the level, actor or other owner object.

This might seem like an unimportant corner case at first, but stepping through the code of the method FPropertyValueImpl::ImportText() on file PropertyHandleImple.cpp:244, it can be noted that the parent FProperty is seen there as a FStructProperty instead of the expected FMapProperty or FSetProperty (same thing on the check in line 442/448). So this might actually be revealing an important bug with other potential consequences elsewhere.

Steps to Reproduce
  • Download the code from this [Link Removed].
  • Put the code in an empty C++ project, compile and run the Editor
  • Create a blueprint and add a Set/Map variable with MyHashableStruct as key.
  • Edit the variable in the Details panel of the blueprint or of an actor instance in the level:
  • Add an entry, which will come with default key “0”
  • Add another entry, this will fail as expected
  • Change the existing entry to have key “1”
  • Add another entry, this will succeed as expected
  • Change the new entry to have hey “1”, this will unexpectedly succeed

[Link Removed] of the context in which the bug is perceived when following the provided repro steps

Have Comments or More Details?

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

Login to Vote

ComponentUE - Editor - Workflow Systems
Affects Versions5.2
CreatedSep 5, 2023
UpdatedJan 19, 2024
View Jira Issue