bCanSaveAllSections
bCanSaveAllSections
#Overview
name: bCanSaveAllSections
The value of this variable can be defined or overridden in .ini config files. 4
.ini config files referencing this setting variable.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bCanSaveAllSections is to control whether all sections in a configuration file can be saved or not. This variable is primarily used in the configuration system of Unreal Engine 5.
The Unreal Engine subsystem that relies on this setting variable is the Core module, specifically the configuration management system. It’s used in the FConfigFile class, which is responsible for handling configuration files (INI files) in the engine.
The value of this variable is set in several places:
- In the FConfigFile constructor, it’s initialized to true by default.
- In the FConfigContext::PerformLoad function, it’s set based on certain conditions like whether it’s a user file or an editor settings file.
This variable interacts with other configuration-related variables and functions, such as SectionsToSave and WriteToStringInternal.
Developers must be aware that:
- This variable determines whether all sections in a config file can be saved or if only specific sections should be saved.
- It affects the behavior of the WriteToStringInternal function, which is used when writing configuration data.
- The default value (true) allows saving all sections, but this can be changed based on the type of configuration file and the context in which it’s loaded.
Best practices when using this variable include:
- Be cautious when modifying its value, as it can affect which sections of a configuration file are saved.
- Consider the implications on performance and disk usage when allowing all sections to be saved, especially for large configuration files.
- Use it in conjunction with other configuration management tools and functions to ensure proper handling of configuration data.
- When creating custom configuration systems, consider implementing a similar mechanism to control which sections can be saved, following Unreal Engine’s pattern.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/Base.ini:8, section: [SectionsToSave]
- INI Section:
SectionsToSave
- Raw value:
false
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseSourceControlSettings.ini:2, section: [SectionsToSave]
- INI Section:
SectionsToSave
- Raw value:
true
- Is Array:
False
Location: <Workspace>/Engine/Config/PluginBase.ini:5, section: [SectionsToSave]
- INI Section:
SectionsToSave
- Raw value:
true
- Is Array:
False
Location: <Workspace>/Engine/Plugins/Interchange/Runtime/Config/BaseInterchange.ini:2, section: [SectionsToSave]
- INI Section:
SectionsToSave
- Raw value:
True
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Misc/ConfigCacheIni.cpp:617
Scope (from outer to inner):
file
function FConfigFile::FConfigFile
Source code excerpt:
, NoSave( false )
, bHasPlatformName( false )
, bCanSaveAllSections( true )
, Name( NAME_None )
, SourceConfigFile(nullptr)
{
FCoreDelegates::TSOnFConfigCreated().Broadcast(this);
}
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Misc/ConfigCacheIni.cpp:1666
Scope (from outer to inner):
file
function void FConfigFile::WriteToStringInternal
Source code excerpt:
// no need to look up the section if it's a default ini, or if we are always saving all sections
const FConfigSection* SectionsToSaveSection = (bIsADefaultIniWrite || bCanSaveAllSections) ? nullptr : FindSection(SectionsToSaveStr);
TArray<FString> SectionsToSave;
if (SectionsToSaveSection != nullptr)
{
// Do not report the read of SectionsToSave. Some ConfigFiles are reallocated without it, and we
// log that the section disappeared. But this log is spurious since the only reason it was read was
// for the internal save before the FConfigFile is made publicly available.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Misc/ConfigContext.cpp:420
Scope (from outer to inner):
file
function bool FConfigContext::PerformLoad
Source code excerpt:
bool bIsEditorSettingsFile = BaseIniName.Contains(TEXT("Editor")) && BaseIniName != TEXT("Editor");
ConfigFile->bCanSaveAllSections = bLocalSaveAllSections || bIsUserFile || bIsEditorSettingsFile;
// don't write anything to disk in cooked builds - we will always use re-generated INI files anyway.
// Note: Unfortunately bAllowGeneratedIniWhenCooked is often true even in shipping builds with cooked data
// due to default parameters. We don't dare change this now.
//
// Check GIsInitialLoad since no INI changes that should be persisted could have occurred this early.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Public/Misc/ConfigCacheIni.h:426
Scope (from outer to inner):
file
class class FConfigFile : private FConfigFileMap
Source code excerpt:
// by default, we allow saving - this is going to be applied to config files that are not loaded from disk
// (when loading, this will get set to false, and then the ini sections will be checked)
bool bCanSaveAllSections : 1; // = true;
/** The name of this config file */
FName Name;
// The collection of source files which were used to generate this file.
FConfigFileHierarchy SourceIniHierarchy;