Merge pull request #81406 from bruvzg/ts_dict_chk2

[TextServer] Pass Dictionary properties by value and check property values instead of references.
This commit is contained in:
Rémi Verschelde 2023-09-08 09:11:23 +02:00
commit 31a7fd1951
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 18 additions and 10 deletions

View File

@ -2383,8 +2383,10 @@ void TextServerAdvanced::_font_set_variation_coordinates(const RID &p_font_rid,
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates;
if (!fd->variation_coordinates.recursive_equal(p_variation_coordinates, 1)) {
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates.duplicate();
}
}
Dictionary TextServerAdvanced::_font_get_variation_coordinates(const RID &p_font_rid) const {

View File

@ -1376,8 +1376,10 @@ void TextServerFallback::_font_set_variation_coordinates(const RID &p_font_rid,
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates;
if (!fd->variation_coordinates.recursive_equal(p_variation_coordinates, 1)) {
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates.duplicate();
}
}
Dictionary TextServerFallback::_font_get_variation_coordinates(const RID &p_font_rid) const {

View File

@ -2819,12 +2819,14 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
}
void FontVariation::set_variation_opentype(const Dictionary &p_coords) {
variation.opentype = p_coords;
_invalidate_rids();
if (!variation.opentype.recursive_equal(p_coords, 1)) {
variation.opentype = p_coords.duplicate();
_invalidate_rids();
}
}
Dictionary FontVariation::get_variation_opentype() const {
return variation.opentype;
return variation.opentype.duplicate();
}
void FontVariation::set_variation_embolden(float p_strength) {
@ -2861,12 +2863,14 @@ int FontVariation::get_variation_face_index() const {
}
void FontVariation::set_opentype_features(const Dictionary &p_features) {
opentype_features = p_features;
_invalidate_rids();
if (!opentype_features.recursive_equal(p_features, 1)) {
opentype_features = p_features.duplicate();
_invalidate_rids();
}
}
Dictionary FontVariation::get_opentype_features() const {
return opentype_features;
return opentype_features.duplicate();
}
void FontVariation::set_spacing(TextServer::SpacingType p_spacing, int p_value) {