Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix editor log flicker. #77973

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions editor/editor_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions scene/gui/rich_text_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ class RichTextLabel : public Control {
bool is_deselect_on_focus_loss_enabled() const;
void deselect();

int get_pending_paragraphs() const;
bool is_ready() const;
bool is_updating() const;

Expand Down