summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2020-07-23 07:51:29 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-07-23 07:58:23 -0300
commitacf32e87d57892e2a8541ab457ad20c9a8500b1b (patch)
tree135cf6d4d7b8062266f3abcbb9457633e277a707 /servers/rendering
parentbd00ab75162fc1cbca539786d50f04b8e5f4024f (diff)
Fixes RenderingServer crashes reported by #39951
Supersedes #40026
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/rendering_server_scene.cpp12
1 files changed, 6 insertions, 6 deletions
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<InstanceLightData *>(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);
}
}