Merge pull request #31641 from Chaosus/vs_fix_preview2

Small performance fix for preview in visual shader
This commit is contained in:
Yuri Roubinsky 2019-08-25 09:40:26 +03:00 committed by GitHub
commit a7aacfef7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View file

@ -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;

View file

@ -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;