diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-06-07 20:09:09 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-06-12 20:15:23 +0300 |
commit | 488626701dc67932f9d6ce82f33bf94aa7cbd45c (patch) | |
tree | 6173910bfba346b6ab4abab4d5b8d3962fc7f7ed | |
parent | 593d5ca29f32d07a8bf9f3bae5b33e67d0f4218f (diff) | |
download | redot-engine-488626701dc67932f9d6ce82f33bf94aa7cbd45c.tar.gz |
Fix editor log flicker.
-rw-r--r-- | editor/editor_log.cpp | 9 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 12 | ||||
-rw-r--r-- | scene/gui/rich_text_label.h | 1 |
3 files changed, 21 insertions, 1 deletions
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index b37debbd70..0fd9d64602 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -346,6 +346,15 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) { } log->add_newline(); + + if (p_replace_previous) { + // Force sync last line update (skip if number of unprocessed log messages is too large to avoid editor lag). + if (log->get_pending_paragraphs() < 100) { + while (!log->is_ready()) { + ::OS::get_singleton()->delay_usec(1); + } + } + } } void EditorLog::_set_filter_active(bool p_active, MessageType p_message_type) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 0819e9305e..65bf47598e 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2741,7 +2741,16 @@ void RichTextLabel::_stop_thread() { } } +int RichTextLabel::get_pending_paragraphs() const { + int to_line = main->first_invalid_line.load(); + int lines = main->lines.size(); + + return lines - to_line; +} + bool RichTextLabel::is_ready() const { + const_cast<RichTextLabel *>(this)->_validate_line_caches(); + if (updating.load()) { return false; } @@ -3177,7 +3186,8 @@ bool RichTextLabel::remove_paragraph(const int p_paragraph) { main->lines[0].from = main; } - main->first_invalid_line.store(0); + int to_line = main->first_invalid_line.load(); + main->first_invalid_line.store(MIN(to_line, p_paragraph)); queue_redraw(); return true; diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index b502e71a4f..cbdad3e4d7 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -684,6 +684,7 @@ public: bool is_deselect_on_focus_loss_enabled() const; void deselect(); + int get_pending_paragraphs() const; bool is_ready() const; bool is_updating() const; |