From ac1f2b378fb669e298a1e61d27617f4561c1af60 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 7 Sep 2022 22:24:30 +0200 Subject: [RTL] Stop threaded RTL auto-redrawing as soon as text processing is finished, instead of waiting for first redraw. --- scene/gui/rich_text_label.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scene') diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 72f5de170c..c936fe9738 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2563,7 +2563,9 @@ bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) { void RichTextLabel::_thread_function(void *self) { RichTextLabel *rtl = reinterpret_cast(self); + rtl->set_physics_process_internal(true); rtl->_process_line_caches(); + rtl->set_physics_process_internal(false); rtl->updating.store(false); rtl->call_deferred(SNAME("queue_redraw")); } @@ -2679,7 +2681,6 @@ bool RichTextLabel::_validate_line_caches() { loaded.store(true); thread.start(RichTextLabel::_thread_function, reinterpret_cast(this)); loading_started = OS::get_singleton()->get_ticks_msec(); - set_physics_process_internal(true); return false; } else { _process_line_caches(); @@ -4367,12 +4368,12 @@ int RichTextLabel::get_visible_paragraph_count() const { } void RichTextLabel::scroll_to_line(int p_line) { - _validate_line_caches(); - if (p_line <= 0) { vscroll->set_value(0); return; } + _validate_line_caches(); + int line_count = 0; int to_line = main->first_invalid_line.load(); for (int i = 0; i < to_line; i++) { -- cgit v1.2.3