From acf32e87d57892e2a8541ab457ad20c9a8500b1b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 23 Jul 2020 07:51:29 -0300 Subject: Fixes RenderingServer crashes reported by #39951 Supersedes #40026 --- servers/rendering/rendering_server_scene.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'servers') diff --git a/servers/rendering/rendering_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp index 75a5834791..2024f5b983 100644 --- a/servers/rendering/rendering_server_scene.cpp +++ b/servers/rendering/rendering_server_scene.cpp @@ -370,8 +370,8 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { case RS::INSTANCE_LIGHT: { InstanceLightData *light = static_cast(instance->base_data); - if (RSG::storage->light_get_type(instance->base) != RS::LIGHT_DIRECTIONAL && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { - instance->scenario->dynamic_lights.erase(light->instance); + if (scenario && RSG::storage->light_get_type(instance->base) != RS::LIGHT_DIRECTIONAL && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { + scenario->dynamic_lights.erase(light->instance); } #ifdef DEBUG_ENABLED @@ -379,8 +379,8 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { ERR_PRINT("BUG, indexing did not unpair geometries from light."); } #endif - if (instance->scenario && light->D) { - instance->scenario->directional_lights.erase(light->D); + if (scenario && light->D) { + scenario->directional_lights.erase(light->D); light->D = nullptr; } RSG::scene_render->free(light->instance); @@ -986,13 +986,13 @@ void RenderingServerScene::_update_instance(Instance *p_instance) { RS::LightBakeMode bake_mode = RSG::storage->light_get_bake_mode(p_instance->base); if (RSG::storage->light_get_type(p_instance->base) != RS::LIGHT_DIRECTIONAL && bake_mode != light->bake_mode) { - if (light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { + if (p_instance->scenario && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { p_instance->scenario->dynamic_lights.erase(light->instance); } light->bake_mode = bake_mode; - if (light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { + if (p_instance->scenario && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { p_instance->scenario->dynamic_lights.push_back(light->instance); } } -- cgit v1.2.3