You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
[Core] Fix property access on read-only Dictionary
This commit is contained in:
@@ -251,15 +251,21 @@ void Variant::set_named(const StringName &p_member, const Variant &p_value, bool
|
||||
return;
|
||||
}
|
||||
} else if (type == Variant::DICTIONARY) {
|
||||
Variant *v = VariantGetInternalPtr<Dictionary>::get_ptr(this)->getptr(p_member);
|
||||
if (v) {
|
||||
*v = p_value;
|
||||
r_valid = true;
|
||||
} else {
|
||||
VariantGetInternalPtr<Dictionary>::get_ptr(this)->operator[](p_member) = p_value;
|
||||
r_valid = true;
|
||||
Dictionary &dict = *VariantGetInternalPtr<Dictionary>::get_ptr(this);
|
||||
|
||||
if (dict.is_read_only()) {
|
||||
r_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Variant *v = dict.getptr(p_member);
|
||||
if (v) {
|
||||
*v = p_value;
|
||||
} else {
|
||||
dict[p_member] = p_value;
|
||||
}
|
||||
|
||||
r_valid = true;
|
||||
} else {
|
||||
r_valid = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user