Skip to content

Commit

Permalink
Merge pull request #70850 from bruvzg/ts_tsafe_free
Browse files Browse the repository at this point in the history
[TextServer] Make `free` calls thread safe.
  • Loading branch information
akien-mga authored Jan 3, 2023
2 parents 1d92b44 + a28e8f0 commit 96f1204
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions modules/text_server_adv/text_server_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,17 @@ void TextServerAdvanced::_free_rid(const RID &p_rid) {
_THREAD_SAFE_METHOD_
if (font_owner.owns(p_rid)) {
FontAdvanced *fd = font_owner.get_or_null(p_rid);
font_owner.free(p_rid);
{
MutexLock lock(fd->mutex);
font_owner.free(p_rid);
}
memdelete(fd);
} else if (shaped_owner.owns(p_rid)) {
ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_rid);
shaped_owner.free(p_rid);
{
MutexLock lock(sd->mutex);
shaped_owner.free(p_rid);
}
memdelete(sd);
}
}
Expand Down
10 changes: 8 additions & 2 deletions modules/text_server_fb/text_server_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,17 @@ void TextServerFallback::_free_rid(const RID &p_rid) {
_THREAD_SAFE_METHOD_
if (font_owner.owns(p_rid)) {
FontFallback *fd = font_owner.get_or_null(p_rid);
font_owner.free(p_rid);
{
MutexLock lock(fd->mutex);
font_owner.free(p_rid);
}
memdelete(fd);
} else if (shaped_owner.owns(p_rid)) {
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_rid);
shaped_owner.free(p_rid);
{
MutexLock lock(sd->mutex);
shaped_owner.free(p_rid);
}
memdelete(sd);
}
}
Expand Down

0 comments on commit 96f1204

Please sign in to comment.