Description

Duplicate key checking in maps and sets in the editor is done via calls to FScriptMapHelper::HasKey() and FScriptSetHelper::HasElement(), but this code is checking for object names which are subsets of existing keys, and so incorrectly reports duplicate keys when adding such a new key.

This is fundamentally an editor issue rather than a Core issue. These two functions are inappropriate for these helpers and should be relocated to the editor as part of any fix.

Steps to Reproduce
  • Create a new project
  • Add some new classes:
    UCLASS()
    class AMyActor : public AActor
    {
    	GENERATED_BODY()
    };
    
    UCLASS()
    class AMyActor2 : public AActor
    {
    	GENERATED_BODY()
    };
    
    UCLASS()
    class AMyActorReference : public AActor
    {
    	GENERATED_BODY()
    
    		UPROPERTY(EditAnywhere, Category = "TestMap")
    		TMap<UObject*, int32> TestMap;
    };
    
  • Compile and run the editor
  • Add an instance of AMyActorReference.
  • In the details panel, find the TestMap property.
  • Add a new element. and assign the key to the AMyActor2 class.
  • Add another new element. and assign the key to the AMyActor class.

Expected: Setting the key works.
Actual: A 'duplicate key' error is raised.

Have Comments or More Details?

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

1
Login to Vote

Backlogged
ComponentUE - Editor - Workflow Systems
Affects Versions4.275.0
CreatedJan 27, 2022
UpdatedJan 19, 2024