Problem with storing c array of structs in the config


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:

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.

Hey DerDodo-

Which config file are you attempting to store your array in? Can you provide the code you’re using to create/store the array as well as any other setup steps needed to reproduce this issue?

Hi DerDodo,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

Hi ,

sorry, I tried to create a minimal example to show the bug, but unfortunately I could not recreate it. But it still appears in our game.

It is not that important since we hacked around it by storing the configuration in a TArray and then synchronize it to our c-array.

Cheers, Dodo