When emptying an array in a config file, I have several occurrences named "__ClearArray__"

Hi, as the title says, I’m experiencing an issue with a plugin I’m developing.
When I remove an item from an array or empty it, I get one or several occurrences of this type:

[/Script/LevelBookmarks.LevelBookmarksDeveloperSettings]
!LevelBookmarks=__ClearArray__
+LevelBookmarks=/Game/Maps/Basic.Basic
+LevelBookmarks=/Game/Maps/OpenWorld.OpenWorld

I tried:

  • to clean the section completely
  • to empty the array, save, adding back all the values minus the ones removed
  • overriding the array with the new one

Nothing worked, any idea on how to solve this?

I’m using this method to save it in the “Config” folder instead of “Saved/Config”

I see you linked an old post of mine, there are other ways to read/write to ini files.
Maybe this is of help, since you are developing your own plugin you might have enough freedom to use the method in my reply here:

How to select on which monitor to display the game ? - #10 by Roy_Wierer.Seda145

In case the link dies, a small example on GConfig:

GConfig->SetString(*Section, *Setting, *Value, GGameUserSettingsIni);
GConfig->Flush(true, GGameUserSettingsIni);

I have never seen this with my methods and I don’t know what ini editing method in specific and engine version you use.

1 Like

I’m just editing a subclass of UDeveloperSettings and saving it with:

Settings->SaveConfig(CPF_Config, *Settings->GetDefaultConfigFilename());

I’m compiling for the latest three engine versions (5.1, 5.2 and 5.3), it will be a free plugin on the marketplace.

I tried to call “Flush” but as you can see the issue still persists:

image

I made this plugin 'cause I wanted to sync these bookmarks in source control, so that other users can see the relevant project maps (what CommonMaps does in Lyra, but it’s a plugin instead of being embedded in the source code)

What exactly this is for I can’t tell without deep diving into it, but it seems there are only 2 files referencing “ClearArray” in UE5.2 . nothing on google.

ConfigCacheIni states on line 2050:
“// look for pointless !Clear entries that the config system wrote out when it noticed the user didn’t have any entries”

The tool I’m using to scan is Agent Ransack

1 Like

Thanks for the tool, I’ve installed it and I’ll probably use it in future, I was using Rider to look for that string and I’ve found the same files you’ve found:

I’ve searched for that __ClearArray__ anywhere and I found nothing, also AI chatbots like Copilot/Codeium/ChatGPT/Claude/Gemini have no idea about that :sweat_smile:

if (ArrayHelper.Num() == 0 && bIsADefaultIniWrite)
{
	const FString EmptyKey = FString::Printf(TEXT("!%s"), *Key);
	Sec->Add(*EmptyKey, TEXT("__ClearArray__"));
}

These lines in Obj.cpp are surely the ones that are adding it, I just can’t find how to clear them, probably making “bIsADefaultIniWrite” false.

I sent you a sample of the plugin in private, but don’t feel obligated to waste your time on it!

Thanks for the code, I scanned over it quickly.
It adds an editor dropdown that you can use to bookmark levels or even any uasset to a list?

I have no idea, I don’t use Lyra :slight_smile:

I agree that having what seems to be garbage like “ClearArray” in your ini does not look clean / professional, but are there any problems left to solve? Sometimes the engine just makes a mess and it’s easier to accept it than to try to hack around it which can lead to actual problems. If you wish to process the bookmarks under the ini section you could filter out that bad line “if string contains !LevelBookmarks then skip”. Is that right?

It’s supposed to work with levels, but actually it works with any asset if you add it manually to the list (levels have a right click option to add them in a faster way)

In theory, no… I’ve already sent the publish request to the Epic Marketplace but I’d like to fix that minor issue since it’s something I’m sharing with the community and not using it for myself only!

I’ve learnt this on my skin! I am a perfectionist with a severe OCD :joy:

The __ClearArray__ thing is not shown in the list, it’s probably something nobody would have even noticed, it’s just the .ini file that is dirty and if you do it several times you’ll find it full of __ClearArray__ lines :sweat_smile:

I’ll probably put something in the plugin shutdown function that deletes all the lines in the .ini file if I don’t find anything better.

If there’s no problem, optionally put it in a “known issues” section and make clear it is no problem, but a leftover of EPICs mess. I know perfectionism. The code written in this engine is no perfectionism :slight_smile: you can’t get around it.

1 Like

If anyone feels like looking at it, here’s the LevelBookmarks UE Marketplace Link, for now I’ll mark it as a “known issue” like @Roy_Wierer.Seda145 suggested!