summaryrefslogtreecommitdiff
path: root/core/config
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-01 07:29:44 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-01 07:29:44 +0100
commit27fdb06fed00a8fe12a02bee17f973eef90d29a0 (patch)
tree1cf12dba7f2ea79f8112d319222e12c248b0e6bc /core/config
parentb7c0f613b5eb1e19d5637c3062f6d8db68236a5e (diff)
parent7c73b6c71cad819cd7c53c8ccf14f7e909203c0d (diff)
Merge pull request #71322 from EricEzaM/55856-proj-settings-initial-array-dict-shared-instance
Fix Project Settings array/dicts initial value being shared instances of the current value.
Diffstat (limited to 'core/config')
-rw-r--r--core/config/project_settings.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index ba9c6e4c60..6a1d802453 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -221,7 +221,9 @@ String ProjectSettings::localize_path(const String &p_path) const {
void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_value) {
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
- props[p_name].initial = p_value;
+
+ // Duplicate so that if value is array or dictionary, changing the setting will not change the stored initial value.
+ props[p_name].initial = p_value.duplicate();
}
void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) {
@@ -1116,7 +1118,9 @@ bool ProjectSettings::_property_get_revert(const StringName &p_name, Variant &r_
return false;
}
- r_property = props[p_name].initial;
+ // Duplicate so that if value is array or dictionary, changing the setting will not change the stored initial value.
+ r_property = props[p_name].initial.duplicate();
+
return true;
}