diff options
Diffstat (limited to 'core/variant/dictionary.cpp')
-rw-r--r-- | core/variant/dictionary.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/variant/dictionary.cpp b/core/variant/dictionary.cpp index 9f65a73c6f..7416101d51 100644 --- a/core/variant/dictionary.cpp +++ b/core/variant/dictionary.cpp @@ -249,6 +249,7 @@ void Dictionary::clear() { } void Dictionary::merge(const Dictionary &p_dictionary, bool p_overwrite) { + ERR_FAIL_COND_MSG(_p->read_only, "Dictionary is in read-only state."); for (const KeyValue<Variant, Variant> &E : p_dictionary._p->variant_map) { if (p_overwrite || !has(E.key)) { operator[](E.key) = E.value; @@ -256,6 +257,12 @@ void Dictionary::merge(const Dictionary &p_dictionary, bool p_overwrite) { } } +Dictionary Dictionary::merged(const Dictionary &p_dictionary, bool p_overwrite) const { + Dictionary ret = duplicate(); + ret.merge(p_dictionary, p_overwrite); + return ret; +} + void Dictionary::_unref() const { ERR_FAIL_NULL(_p); if (_p->refcount.unref()) { |