This question was created in reference to: [Array in .ini file not preserving [Content removed]
I’m seeing the same issue and can’t figure out a way around it. Reproduction steps attached.
This question was created in reference to: [Array in .ini file not preserving [Content removed]
I’m seeing the same issue and can’t figure out a way around it. Reproduction steps attached.
Steps to Reproduce
Hi Ben,
Thank you for the report and repro steps. I was able to reproduce this behavior on my end here.
After investigating the source code, it appears that saving a TArray containing duplicate values in a config file that is part of the Default INI hierarchy is not supported. The reason lies in file [Obj.cpp], function UObject::SaveConfig(), line 3548 (considering vanilla UE 5.6 from the launcher), where “FString CompleteKey” is calculated:
FString CompleteKey = FString::Printf(TEXT("%s%s"), bIsADefaultIniWrite ? TEXT("+") : TEXT(""), *Key);The code above always forces the prefix “+” (never “.”) for this kind of config file. And I also checked that the problem still exists on the latest engine version from the repo. I guess that using prefix “.” was never needed for the built-in settings. “AutoCompleteMapPaths”, for example, does not need duplicate entries, but let me know if you can find a setting where they should be allowed, since this would help us flag this issue as a bug instead of a missing feature. In any case, I am investigating a little more before passing this on to the engine devs.
Now, I understand that you want to create some settings of your own, and include a TArray where duplicate values are desirable. One possible workaround for this is to use a fixed-size array instead of a TArray, if it is acceptable for your use case. Otherwise, I can think of a fairly simple engine modification to add the functionality you need. Basically, you could create a Property Meta to indicate that a TArray property should be saved to config files with “.” instead of “+”. On your settings class, you would have:
UPROPERTY(EditAnywhere, Config, Meta = (ConfigAllowDuplicates))Then, on UObject::SaveConfig(), when calculating “CompleteKey”, you would be able to query that metadata to choose the appropriate prefix:
Property->HasMetaData(TEXT("ConfigAllowDuplicates")) ? TEXT(".") : TEXT("+")Let me know if this helps!
Best regards,
Vitor
Thanks Vitor! Adding a meta tag worked great.
I hope this is a change that could be rolled back into the engine.