Description

The Contains node doesn't return an existing row from a data table under specific circumstances. This didn't occur when the struct the data table is based on was made via blueprints or there are more than 4 keys.

Attached is a repro project.

Found in 4.23.1 CL#9631420
Reproduced in 4.24 Preview 3 CL#10283392, 4.25 Main CL#100307320

Steps to Reproduce

1. Define a data table row (CustomDataTableRow) that contains a TMap with a int32 key and FTransfrom element.
2. Create a data table asset(CustomDataTable) using CustomDataTableRow.
3. Add a row to CustomDataTable (TestRow)
4. Add 4 elements to TestRow where the the first element uses 1 for the key, the second element uses 2 for the key, the third element uses 3 for the key, the 4th element uses 4 for the key.
NOTE: Adding a fifth will break cause the repro steps to fail.
4. Create a blueprint (TestBP) with a DataTableAsset of type CustomDataTable.
5. In TestBP create code to check whether a key of value 4 is stored in TestRow. A call in editor event was easy.
6. Check whether the 4th element was found.

Result: The 4th key isn't found.

Expected: The 4th key is found.

 

 

Workaround: Restart the editor and the key will be found

Update: 

This looks to be a problem more specifically with how maps are created in data tables. The .Contains method fails on a map from a Data table in both BP and C++ 

The problem is originating because the `HashIndex` of the last element in the data table map is always 0. This results in .Contains returning false in both c++ and Blueprint for maps created in data tables. Maybe this is caused by some improper type being used for the hash function? Or possibly an off by one error involving a modulus somewhere? 

Update: This look likes a problem with how FScriptMapHelper::Rehash() works when it gets called from PropertyHandleImpl.cpp

Have Comments or More Details?

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

4
Login to Vote

Fixed
ComponentTools
Affects Versions4.23.14.244.25
Target Fix4.26
Fix Commit12651655
Main Commit13519561
CreatedNov 20, 2019
ResolvedMay 14, 2020
UpdatedNov 5, 2020