From 831860695c8404720f4b7d2e0a4d93ad2f308c21 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 12 Jun 2017 19:23:37 -0300 Subject: [PATCH] Fix empty shader related crash, closes #8314 --- drivers/gles3/rasterizer_scene_gles3.cpp | 2 +- drivers/gles3/rasterizer_storage_gles3.cpp | 5 +++++ editor/plugins/shader_editor_plugin.cpp | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 08f15a9b846..87347b8d95a 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -2113,7 +2113,7 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo if (m_src.is_valid()) { m = storage->material_owner.getornull(m_src); - if (!m->shader) { + if (!m->shader || !m->shader->valid) { m = NULL; } } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 54e99eb622e..858c543785d 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1425,6 +1425,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const { _shader_dirty_list.remove(&p_shader->dirty_list); p_shader->valid = false; + p_shader->ubo_size = 0; p_shader->uniforms.clear(); @@ -2244,6 +2245,10 @@ void RasterizerStorageGLES3::_update_material(Material *material) { if (material->shader && material->shader->dirty_list.in_list()) { _update_shader(material->shader); } + + if (material->shader && !material->shader->valid) + return; + //update caches { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 8ae7d55bdd2..7c8ee97f227 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -552,7 +552,8 @@ ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) { shader_editor = memnew(ShaderEditor); shader_editor->set_custom_minimum_size(Size2(0, 300)); - button = editor->add_bottom_panel_item("Shader", shader_editor); + button = editor->add_bottom_panel_item(TTR("Shader"), shader_editor); + button->hide(); } ShaderEditorPlugin::~ShaderEditorPlugin() {