diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-30 20:47:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 20:47:31 +0200 |
commit | fd0775398b5fa5f0300b37e29961493416ec83d2 (patch) | |
tree | d991364ebebff27b5ad9ed8d30357ef41d66182f | |
parent | bc8a85b3e096ccd33559c8a868eaaf1725aa593c (diff) | |
parent | edc858ad82c2c7a430bc2b7f5ee161e2d0683229 (diff) |
Merge pull request #51078 from nekomatata/code-editor-theme-change-optimization
Optimize theme change in code editor
-rw-r--r-- | editor/code_editor.cpp | 12 | ||||
-rw-r--r-- | editor/code_editor.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 03695419cb..285084a72b 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -31,6 +31,7 @@ #include "code_editor.h" #include "core/input/input.h" +#include "core/object/message_queue.h" #include "core/os/keyboard.h" #include "core/string/string_builder.h" #include "editor/editor_scale.h" @@ -1567,6 +1568,17 @@ void CodeTextEditor::_update_font() { } void CodeTextEditor::_on_settings_change() { + if (settings_changed) { + return; + } + + settings_changed = true; + MessageQueue::get_singleton()->push_callable(callable_mp(this, &CodeTextEditor::_apply_settings_change)); +} + +void CodeTextEditor::_apply_settings_change() { + settings_changed = false; + _update_text_editor_theme(); _update_font(); diff --git a/editor/code_editor.h b/editor/code_editor.h index 0e5a84b3d5..4cd4880df0 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -162,7 +162,10 @@ class CodeTextEditor : public VBoxContainer { int error_line; int error_column; + bool settings_changed = false; + void _on_settings_change(); + void _apply_settings_change(); void _update_text_editor_theme(); void _update_font(); |