mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Fix Dictionary::operator[] from C++ accidentally modifying const dictionaries.
Fix `AudioStreamWav` inserting keys into the input dictionary.
This commit is contained in:
parent
4fcd85551c
commit
0be2a77156
2 changed files with 14 additions and 12 deletions
|
|
@ -127,8 +127,10 @@ const Variant &Dictionary::operator[](const Variant &p_key) const {
|
|||
VariantInternal::initialize(_p->typed_fallback, _p->typed_value.type);
|
||||
return *_p->typed_fallback;
|
||||
} else {
|
||||
// Will not insert key, so no initialization is necessary.
|
||||
return _p->variant_map[key];
|
||||
static Variant empty;
|
||||
const Variant *value = _p->variant_map.getptr(key);
|
||||
ERR_FAIL_COND_V_MSG(!value, empty, "Bug: Dictionary::operator[] used when there was no value for the given key, please report.");
|
||||
return *value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue