Ensure shader is not set if code did not change

This commit is contained in:
Juan Linietsky 2019-03-04 19:37:05 -03:00
parent 26c1d1aec8
commit 5b77aa6bea
2 changed files with 15 additions and 4 deletions

View file

@ -2591,7 +2591,8 @@ void EditorPropertyResource::_resource_selected() {
if (use_sub_inspector) {
get_edited_object()->editor_set_section_unfold(get_edited_property(), assign->is_pressed());
bool unfold = !get_edited_object()->editor_is_section_unfolded(get_edited_property());
get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold);
update_property();
} else {
@ -2775,7 +2776,7 @@ void EditorPropertyResource::_bind_methods() {
EditorPropertyResource::EditorPropertyResource() {
opened_editor = true;
opened_editor = false;
sub_inspector = NULL;
sub_inspector_vbox = NULL;
use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector"));

View file

@ -47,6 +47,9 @@ Ref<Shader> ShaderTextEditor::get_edited_shader() const {
}
void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
if (shader == p_shader) {
return;
}
shader = p_shader;
_load_theme_settings();
@ -415,6 +418,9 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) {
if (p_shader.is_null() || !p_shader->is_text_shader())
return;
if (shader == p_shader)
return;
shader = p_shader;
shader_editor->set_edited_shader(p_shader);
@ -438,8 +444,12 @@ void ShaderEditor::save_external_data() {
void ShaderEditor::apply_shaders() {
if (shader.is_valid()) {
shader->set_code(shader_editor->get_text_edit()->get_text());
shader->set_edited(true);
String shader_code = shader->get_code();
String editor_code = shader_editor->get_text_edit()->get_text();
if (shader_code != editor_code) {
shader->set_code(editor_code);
shader->set_edited(true);
}
}
}