summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2019-08-25 09:40:26 +0300
committerGitHub <noreply@github.com>2019-08-25 09:40:26 +0300
commita7aacfef7f0753034d6ac468dba4574f8d04d357 (patch)
treecf3ec2bba17e772de09eb745a8e28fb72eedd085
parent38ba150800be99bab08e38cd8cab0cd6b6b9216a (diff)
parent494ea78610c267f34c231c7ace9b98f4d87a6f99 (diff)
Merge pull request #31641 from Chaosus/vs_fix_preview2
Small performance fix for preview in visual shader
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp22
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h1
2 files changed, 13 insertions, 10 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 0bfe366a6d..55ff3fc3dd 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -2058,16 +2058,20 @@ void VisualShaderEditor::_show_preview_text() {
preview_showed = !preview_showed;
preview_vbox->set_visible(preview_showed);
if (preview_showed) {
- if (shader_error) {
- error_text->set_visible(true);
- } else {
- error_text->set_visible(false);
+ if (pending_update_preview) {
+ _update_preview();
+ pending_update_preview = false;
}
}
}
void VisualShaderEditor::_update_preview() {
+ if (!preview_showed) {
+ pending_update_preview = true;
+ return;
+ }
+
String code = visual_shader->get_code();
preview_text->set_text(code);
@@ -2081,16 +2085,13 @@ void VisualShaderEditor::_update_preview() {
}
if (err != OK) {
preview_text->set_line_as_marked(sl.get_error_line() - 1, true);
- if (preview_showed) {
- error_text->set_visible(true);
- }
+ error_text->set_visible(true);
+
String text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
error_text->set_text(text);
shader_error = true;
} else {
- if (preview_showed) {
- error_text->set_visible(false);
- }
+ error_text->set_visible(false);
shader_error = false;
}
}
@@ -2163,6 +2164,7 @@ VisualShaderEditor::VisualShaderEditor() {
ShaderLanguage::get_keyword_list(&keyword_list);
preview_showed = false;
+ pending_update_preview = false;
shader_error = false;
to_node = -1;
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 5be214f9a9..a2e9516a6e 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -70,6 +70,7 @@ class VisualShaderEditor : public VBoxContainer {
PanelContainer *error_panel;
Label *error_label;
+ bool pending_update_preview;
bool shader_error;
VBoxContainer *preview_vbox;
TextEdit *preview_text;