Hi,
I currently experience an issue with storing c arrays of structs in the config.
Specifically: It sometimes does not save my values.
I debugged the code and it looks like an issue in Obj.cpp, Obj::SaveConfig()
Specifically this loop:
TCHAR TempKey[MAX_SPRINTF]=TEXT("");
for( int32 Index=0; Index<Property->ArrayDim; Index++ )
{
if ( !bShouldCheckIfIdenticalBeforeAdding || !Property->Identical_InContainer(this, SuperClassDefaultObject, Index) )
{
if( Property->ArrayDim!=1 )
{
FCString::Sprintf( TempKey, TEXT("%s[%i]"), *Property->GetName(), Index );
Key = TempKey;
}
FString Value;
Property->ExportText_InContainer( Index, Value, this, this, this, PortFlags );
Config->SetString( *Section, *Key, *Value, *PropFileName );
}
else if( Property->Identical_InContainer(this, SuperClassDefaultObject, Index) )
{
// If we are not writing it to config above, we should make sure that this property isn't stagnant in the cache.
FConfigSection* Sec = Config->GetSectionPrivate( *Section, 1, 0, *PropFileName );
if( Sec )
{
Sec->Remove( *Key );
}
}
}
If you have an array “myArray” of three elements and only the element Index 1 is changed:
- Index 0: First if fails, second if succeeds, he finds the section, he tries to remove the key “myArray”
- Index 1: First if succeeds, he creates the key “myArray[1]”, the value is added
- Index 2: First if fails, second if succeeds, he finds the section, he removes “myArray[1]” again
So effectively no value is stored.