[TextServer] Make free calls thread safe.

This commit is contained in:
bruvzg
2023-01-02 21:59:05 +02:00
parent b29bb11a4c
commit a28e8f0c8d
2 changed files with 16 additions and 4 deletions

View File

@@ -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);
}
}