1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-06 19:41:11 +00:00

[TextServer] Fix duplicated losing span info, and RID leak.

This commit is contained in:
Pāvels Nadtočajevs
2025-12-11 21:50:22 +02:00
parent 14e840dd75
commit 8fa484f331
4 changed files with 19 additions and 3 deletions

View File

@@ -4495,9 +4495,10 @@ RID TextServerAdvanced::_shaped_text_duplicate(const RID &p_shaped) {
MutexLock lock(sd->mutex);
ShapedTextDataAdvanced *new_sd = memnew(ShapedTextDataAdvanced);
new_sd->parent = p_shaped;
new_sd->start = sd->start;
new_sd->end = sd->end;
new_sd->first_span = sd->first_span;
new_sd->last_span = sd->last_span;
new_sd->text = sd->text;
new_sd->hb_buffer = hb_buffer_create();
new_sd->utf16 = new_sd->text.utf16();
@@ -4517,7 +4518,12 @@ RID TextServerAdvanced::_shaped_text_duplicate(const RID &p_shaped) {
for (int i = 0; i < TextServer::SPACING_MAX; i++) {
new_sd->extra_spacing[i] = sd->extra_spacing[i];
}
full_copy(new_sd);
for (const KeyValue<Variant, ShapedTextDataAdvanced::EmbeddedObject> &E : sd->objects) {
new_sd->objects[E.key] = E.value;
}
for (int i = 0; i < sd->spans.size(); i++) {
new_sd->spans.push_back(sd->spans[i]);
}
new_sd->valid.clear();
return shaped_owner.make_rid(new_sd);