diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-03 12:22:24 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-03 12:22:24 +0100 |
commit | 1b634c06d08c99f176122331f697e6525a76bf01 (patch) | |
tree | b4d51265754a7dd4b63c4fb394649f17ef3bad16 /scene | |
parent | 5638fcdd7109e9827bd4f8c05a886eff74bfc021 (diff) | |
parent | ea33001b95d57f7b400d78d4b20bef23293d9077 (diff) |
Merge pull request #69972 from adamscott/add-server-checks-before-free
Add safety-checks before some servers `free()`
Diffstat (limited to 'scene')
56 files changed, 103 insertions, 1 deletions
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index df75d34e0f..fccaf63319 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -661,5 +661,6 @@ CollisionObject2D::CollisionObject2D() { } CollisionObject2D::~CollisionObject2D() { + ERR_FAIL_NULL(PhysicsServer2D::get_singleton()); PhysicsServer2D::get_singleton()->free(rid); } diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index c6296f4732..68dc85486d 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -1507,6 +1507,7 @@ CPUParticles2D::CPUParticles2D() { } CPUParticles2D::~CPUParticles2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(multimesh); RS::get_singleton()->free(mesh); } diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index ccbc080768..95e24028a6 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -688,6 +688,7 @@ GPUParticles2D::GPUParticles2D() { } GPUParticles2D::~GPUParticles2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(particles); RS::get_singleton()->free(mesh); } diff --git a/scene/2d/joint_2d.cpp b/scene/2d/joint_2d.cpp index 3ec744ff8e..9e12c7aa3b 100644 --- a/scene/2d/joint_2d.cpp +++ b/scene/2d/joint_2d.cpp @@ -246,6 +246,7 @@ Joint2D::Joint2D() { } Joint2D::~Joint2D() { + ERR_FAIL_NULL(PhysicsServer2D::get_singleton()); PhysicsServer2D::get_singleton()->free(joint); } diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 78b5199358..e07393a9c7 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -321,6 +321,7 @@ Light2D::Light2D() { } Light2D::~Light2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(canvas_light); } diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 67e82140e4..e7997c6eff 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -148,6 +148,7 @@ OccluderPolygon2D::OccluderPolygon2D() { } OccluderPolygon2D::~OccluderPolygon2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(occ_polygon); } @@ -291,5 +292,7 @@ LightOccluder2D::LightOccluder2D() { } LightOccluder2D::~LightOccluder2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); + RS::get_singleton()->free(occluder); } diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index 62afe0d89b..4455142a6c 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -197,6 +197,7 @@ NavigationAgent2D::NavigationAgent2D() { } NavigationAgent2D::~NavigationAgent2D() { + ERR_FAIL_NULL(NavigationServer2D::get_singleton()); NavigationServer2D::get_singleton()->free(agent); agent = RID(); // Pointless } diff --git a/scene/2d/navigation_link_2d.cpp b/scene/2d/navigation_link_2d.cpp index d639e1cc89..34005dbd9e 100644 --- a/scene/2d/navigation_link_2d.cpp +++ b/scene/2d/navigation_link_2d.cpp @@ -285,6 +285,7 @@ NavigationLink2D::NavigationLink2D() { } NavigationLink2D::~NavigationLink2D() { + ERR_FAIL_NULL(NavigationServer2D::get_singleton()); NavigationServer2D::get_singleton()->free(link); link = RID(); } diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp index cbec4db4c5..4d9d46fb06 100644 --- a/scene/2d/navigation_obstacle_2d.cpp +++ b/scene/2d/navigation_obstacle_2d.cpp @@ -116,6 +116,7 @@ NavigationObstacle2D::NavigationObstacle2D() { } NavigationObstacle2D::~NavigationObstacle2D() { + ERR_FAIL_NULL(NavigationServer2D::get_singleton()); NavigationServer2D::get_singleton()->free(agent); agent = RID(); // Pointless } diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index 675ef7c780..78c65256e8 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -343,6 +343,7 @@ NavigationRegion2D::NavigationRegion2D() { } NavigationRegion2D::~NavigationRegion2D() { + ERR_FAIL_NULL(NavigationServer2D::get_singleton()); NavigationServer2D::get_singleton()->free(region); #ifdef DEBUG_ENABLED diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index e41664b006..5b00a3a2dc 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -664,6 +664,7 @@ Polygon2D::Polygon2D() { Polygon2D::~Polygon2D() { // This will free the internally-allocated mesh instance, if allocated. + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), RID()); RS::get_singleton()->free(mesh); } diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 62787d4488..fa0358fabc 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -529,6 +529,7 @@ Bone2D::Bone2D() { Bone2D::~Bone2D() { #ifdef TOOLS_ENABLED if (!editor_gizmo_rid.is_null()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(editor_gizmo_rid); } #endif // TOOLS_ENABLED @@ -803,5 +804,6 @@ Skeleton2D::Skeleton2D() { } Skeleton2D::~Skeleton2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(skeleton); } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 3136752a2e..f52dbd1c53 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1108,6 +1108,7 @@ void TileMap::_rendering_update_layer(int p_layer) { void TileMap::_rendering_cleanup_layer(int p_layer) { ERR_FAIL_INDEX(p_layer, (int)layers.size()); + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer *rs = RenderingServer::get_singleton(); if (layers[p_layer].canvas_item.is_valid()) { rs->free(layers[p_layer].canvas_item); @@ -1280,6 +1281,7 @@ void TileMap::_rendering_create_quadrant(TileMapQuadrant *p_quadrant) { } void TileMap::_rendering_cleanup_quadrant(TileMapQuadrant *p_quadrant) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); // Free the canvas items. for (const RID &ci : p_quadrant->canvas_items) { RenderingServer::get_singleton()->free(ci); @@ -1596,6 +1598,7 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r void TileMap::_physics_cleanup_quadrant(TileMapQuadrant *p_quadrant) { // Remove a quadrant. + ERR_FAIL_NULL(PhysicsServer2D::get_singleton()); for (RID body : p_quadrant->bodies) { bodies_coords.erase(body); PhysicsServer2D::get_singleton()->free(body); @@ -1754,6 +1757,7 @@ void TileMap::_navigation_update_dirty_quadrants(SelfList<TileMapQuadrant>::List void TileMap::_navigation_cleanup_quadrant(TileMapQuadrant *p_quadrant) { // Clear navigation shapes in the quadrant. + ERR_FAIL_NULL(NavigationServer2D::get_singleton()); for (const KeyValue<Vector2i, Vector<RID>> &E : p_quadrant->navigation_regions) { for (int i = 0; i < E.value.size(); i++) { RID region = E.value[i]; diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 2a50575749..03c24e63ef 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -744,8 +744,10 @@ Camera3D::Camera3D() { } Camera3D::~Camera3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(camera); if (pyramid_shape.is_valid()) { + ERR_FAIL_NULL(PhysicsServer3D::get_singleton()); PhysicsServer3D::get_singleton()->free(pyramid_shape); } } diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index 66546092f2..1b94ff822c 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -352,6 +352,8 @@ void CollisionObject3D::_shape_changed(const Ref<Shape3D> &p_shape) { } void CollisionObject3D::_update_debug_shapes() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); + if (!is_inside_tree()) { debug_shapes_to_update.clear(); return; @@ -393,6 +395,8 @@ void CollisionObject3D::_update_debug_shapes() { } void CollisionObject3D::_clear_debug_shapes() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); + for (KeyValue<uint32_t, ShapeData> &E : shapes) { ShapeData &shapedata = E.value; ShapeData::ShapeBase *shape_bases = shapedata.shapes.ptrw(); @@ -627,6 +631,7 @@ int CollisionObject3D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape } void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); ERR_FAIL_COND(!shapes.has(p_owner)); ERR_FAIL_INDEX(p_shape, shapes[p_owner].shapes.size()); @@ -722,5 +727,6 @@ CollisionObject3D::CollisionObject3D() { } CollisionObject3D::~CollisionObject3D() { + ERR_FAIL_NULL(PhysicsServer3D::get_singleton()); PhysicsServer3D::get_singleton()->free(rid); } diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 5ac8535bb6..6d47375589 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -1701,5 +1701,6 @@ CPUParticles3D::CPUParticles3D() { } CPUParticles3D::~CPUParticles3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(multimesh); } diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index fc442986a8..ee1086fb88 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -254,5 +254,6 @@ Decal::Decal() { } Decal::~Decal() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(decal); } diff --git a/scene/3d/fog_volume.cpp b/scene/3d/fog_volume.cpp index 4606e70310..d9912c47b1 100644 --- a/scene/3d/fog_volume.cpp +++ b/scene/3d/fog_volume.cpp @@ -118,5 +118,6 @@ FogVolume::FogVolume() { } FogVolume::~FogVolume() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(volume); } diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index 17dfe2610e..6302a9e1b8 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -634,5 +634,6 @@ GPUParticles3D::GPUParticles3D() { } GPUParticles3D::~GPUParticles3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(particles); } diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index 476820b1c4..f6546b2d1f 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -58,6 +58,7 @@ GPUParticlesCollision3D::GPUParticlesCollision3D(RS::ParticlesCollisionType p_ty } GPUParticlesCollision3D::~GPUParticlesCollision3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(collision); } @@ -819,6 +820,7 @@ GPUParticlesAttractor3D::GPUParticlesAttractor3D(RS::ParticlesCollisionType p_ty set_base(collision); } GPUParticlesAttractor3D::~GPUParticlesAttractor3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(collision); } diff --git a/scene/3d/joint_3d.cpp b/scene/3d/joint_3d.cpp index 1a18f43e7b..d86c156d99 100644 --- a/scene/3d/joint_3d.cpp +++ b/scene/3d/joint_3d.cpp @@ -234,6 +234,7 @@ Joint3D::Joint3D() { } Joint3D::~Joint3D() { + ERR_FAIL_NULL(PhysicsServer3D::get_singleton()); PhysicsServer3D::get_singleton()->free(joint); } diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp index 262dc0db37..d3020fc5b7 100644 --- a/scene/3d/label_3d.cpp +++ b/scene/3d/label_3d.cpp @@ -966,6 +966,7 @@ Label3D::~Label3D() { TS->free_rid(text_rid); + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(mesh); for (KeyValue<SurfaceKey, SurfaceData> E : surfaces) { RenderingServer::get_singleton()->free(E.value.material); diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 3f43e718b8..23a08f0292 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -476,6 +476,7 @@ Light3D::Light3D() { } Light3D::~Light3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->instance_set_base(get_instance(), RID()); if (light.is_valid()) { diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index 1b5427c80d..108bbe072e 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -313,6 +313,7 @@ LightmapGIData::LightmapGIData() { } LightmapGIData::~LightmapGIData() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(lightmap); } diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 741f7397ad..3acb33f42a 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -204,6 +204,7 @@ NavigationAgent3D::NavigationAgent3D() { } NavigationAgent3D::~NavigationAgent3D() { + ERR_FAIL_NULL(NavigationServer3D::get_singleton()); NavigationServer3D::get_singleton()->free(agent); agent = RID(); // Pointless } diff --git a/scene/3d/navigation_link_3d.cpp b/scene/3d/navigation_link_3d.cpp index bee7c7f39b..009abfc8fd 100644 --- a/scene/3d/navigation_link_3d.cpp +++ b/scene/3d/navigation_link_3d.cpp @@ -227,10 +227,12 @@ NavigationLink3D::NavigationLink3D() { } NavigationLink3D::~NavigationLink3D() { + ERR_FAIL_NULL(NavigationServer3D::get_singleton()); NavigationServer3D::get_singleton()->free(link); link = RID(); #ifdef DEBUG_ENABLED + ERR_FAIL_NULL(RenderingServer::get_singleton()); if (debug_instance.is_valid()) { RenderingServer::get_singleton()->free(debug_instance); } diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index f241d65649..6431bd2b77 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -122,6 +122,7 @@ NavigationObstacle3D::NavigationObstacle3D() { } NavigationObstacle3D::~NavigationObstacle3D() { + ERR_FAIL_NULL(NavigationServer3D::get_singleton()); NavigationServer3D::get_singleton()->free(agent); agent = RID(); // Pointless } diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 86b78f847e..0e0233c0cd 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -375,12 +375,15 @@ NavigationRegion3D::~NavigationRegion3D() { if (navigation_mesh.is_valid()) { navigation_mesh->disconnect("changed", callable_mp(this, &NavigationRegion3D::_navigation_changed)); } + ERR_FAIL_NULL(NavigationServer3D::get_singleton()); NavigationServer3D::get_singleton()->free(region); #ifdef DEBUG_ENABLED NavigationServer3D::get_singleton_mut()->disconnect("map_changed", callable_mp(this, &NavigationRegion3D::_navigation_map_changed)); NavigationServer3D::get_singleton_mut()->disconnect("navigation_debug_changed", callable_mp(this, &NavigationRegion3D::_update_debug_mesh)); NavigationServer3D::get_singleton_mut()->disconnect("navigation_debug_changed", callable_mp(this, &NavigationRegion3D::_update_debug_edge_connections_mesh)); + + ERR_FAIL_NULL(RenderingServer::get_singleton()); if (debug_instance.is_valid()) { RenderingServer::get_singleton()->free(debug_instance); } diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp index f150a602b3..7166d99b92 100644 --- a/scene/3d/occluder_instance_3d.cpp +++ b/scene/3d/occluder_instance_3d.cpp @@ -139,6 +139,7 @@ Occluder3D::Occluder3D() { Occluder3D::~Occluder3D() { if (occluder.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(occluder); } } diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 02ab297d8e..ea0cfce987 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -40,6 +40,7 @@ Path3D::Path3D() { } Path3D::~Path3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); if (debug_instance.is_valid()) { RS::get_singleton()->free(debug_instance); } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index d29f337fc8..93d3039494 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -3358,6 +3358,7 @@ PhysicalBone3D::~PhysicalBone3D() { if (joint_data) { memdelete(joint_data); } + ERR_FAIL_NULL(PhysicsServer3D::get_singleton()); PhysicsServer3D::get_singleton()->free(joint); } diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index bc3cc31963..f8164ee1aa 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -257,5 +257,6 @@ ReflectionProbe::ReflectionProbe() { } ReflectionProbe::~ReflectionProbe() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(probe); } diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index b205c2cde0..27310e7cee 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -58,10 +58,10 @@ Ref<Skin> SkinReference::get_skin() const { } SkinReference::~SkinReference() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); if (skeleton_node) { skeleton_node->skin_bindings.erase(this); } - RS::get_singleton()->free(skeleton); } diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 1814baa9e9..31d3f1aeb7 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -704,6 +704,7 @@ SoftBody3D::SoftBody3D() : SoftBody3D::~SoftBody3D() { memdelete(rendering_server_handler); + ERR_FAIL_NULL(PhysicsServer3D::get_singleton()); PhysicsServer3D::get_singleton()->free(physics_rid); } diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index e488ff3059..3629464cd1 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -611,6 +611,7 @@ SpriteBase3D::SpriteBase3D() { } SpriteBase3D::~SpriteBase3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(mesh); RenderingServer::get_singleton()->free(material); } diff --git a/scene/3d/visible_on_screen_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp index 6d4c18a69e..70c9321338 100644 --- a/scene/3d/visible_on_screen_notifier_3d.cpp +++ b/scene/3d/visible_on_screen_notifier_3d.cpp @@ -99,6 +99,7 @@ VisibleOnScreenNotifier3D::VisibleOnScreenNotifier3D() { VisibleOnScreenNotifier3D::~VisibleOnScreenNotifier3D() { RID base_old = get_base(); set_base(RID()); + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(base_old); } diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index 3b21f5c03a..07ca63dcd6 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -157,6 +157,7 @@ VisualInstance3D::VisualInstance3D() { } VisualInstance3D::~VisualInstance3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(instance); } diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index 7caf2f4874..2cb15715c6 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -242,6 +242,7 @@ VoxelGIData::VoxelGIData() { } VoxelGIData::~VoxelGIData() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(probe); } @@ -516,5 +517,6 @@ VoxelGI::VoxelGI() { } VoxelGI::~VoxelGI() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(voxel_gi); } diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index f3812eb497..404c289a6a 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -1305,6 +1305,7 @@ CanvasItem::CanvasItem() : } CanvasItem::~CanvasItem() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(canvas_item); } @@ -1459,5 +1460,6 @@ CanvasTexture::CanvasTexture() { canvas_texture = RS::get_singleton()->canvas_texture_create(); } CanvasTexture::~CanvasTexture() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(canvas_texture); } diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index 97b784e9d0..2aa8df10ab 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -360,5 +360,6 @@ CanvasLayer::CanvasLayer() { } CanvasLayer::~CanvasLayer() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(canvas); } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index afc31ae480..c0b81c9b9a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -80,6 +80,7 @@ void ViewportTexture::setup_local_to_scene() { vp->viewport_textures.insert(this); + ERR_FAIL_NULL(RenderingServer::get_singleton()); if (proxy_ph.is_valid()) { RS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid); RS::get_singleton()->free(proxy_ph); @@ -153,6 +154,8 @@ ViewportTexture::~ViewportTexture() { vp->viewport_textures.erase(this); } + ERR_FAIL_NULL(RenderingServer::get_singleton()); + if (proxy_ph.is_valid()) { RS::get_singleton()->free(proxy_ph); } @@ -301,6 +304,8 @@ void Viewport::_sub_window_remove(Window *p_window) { int index = _sub_window_find(p_window); ERR_FAIL_COND(index == -1); + ERR_FAIL_NULL(RenderingServer::get_singleton()); + RS::get_singleton()->free(gui.sub_windows[index].canvas_item); gui.sub_windows.remove_at(index); @@ -4117,6 +4122,7 @@ Viewport::~Viewport() { for (ViewportTexture *E : viewport_textures) { E->vp = nullptr; } + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(viewport); } diff --git a/scene/resources/camera_attributes.cpp b/scene/resources/camera_attributes.cpp index 8e4876e01f..292accddc1 100644 --- a/scene/resources/camera_attributes.cpp +++ b/scene/resources/camera_attributes.cpp @@ -135,6 +135,7 @@ CameraAttributes::CameraAttributes() { } CameraAttributes::~CameraAttributes() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(camera_attributes); } diff --git a/scene/resources/canvas_item_material.cpp b/scene/resources/canvas_item_material.cpp index b16059c218..0cc5faffb1 100644 --- a/scene/resources/canvas_item_material.cpp +++ b/scene/resources/canvas_item_material.cpp @@ -294,6 +294,8 @@ CanvasItemMaterial::CanvasItemMaterial() : CanvasItemMaterial::~CanvasItemMaterial() { MutexLock lock(material_mutex); + ERR_FAIL_NULL(RenderingServer::get_singleton()); + if (shader_map.has(current_key)) { shader_map[current_key].users--; if (shader_map[current_key].users == 0) { diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 23bd8a4be4..f97cffc3fc 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -1550,5 +1550,6 @@ Environment::Environment() { } Environment::~Environment() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(environment); } diff --git a/scene/resources/fog_material.cpp b/scene/resources/fog_material.cpp index 46b44d681f..2aca552716 100644 --- a/scene/resources/fog_material.cpp +++ b/scene/resources/fog_material.cpp @@ -132,6 +132,7 @@ void FogMaterial::_bind_methods() { void FogMaterial::cleanup_shader() { if (shader.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(shader); } } diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index 90cc3ea5f4..2defe729cc 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -410,5 +410,6 @@ ImmediateMesh::ImmediateMesh() { mesh = RS::get_singleton()->mesh_create(); } ImmediateMesh::~ImmediateMesh() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(mesh); } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index a16d2c2072..44ce90cc4a 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -141,6 +141,7 @@ Material::Material() { } Material::~Material() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(material); } @@ -3005,6 +3006,7 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) : } BaseMaterial3D::~BaseMaterial3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); MutexLock lock(material_mutex); if (shader_map.has(current_key)) { diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index af770ddede..a610290a11 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -2117,6 +2117,7 @@ ArrayMesh::ArrayMesh() { ArrayMesh::~ArrayMesh() { if (mesh.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(mesh); } } @@ -2132,5 +2133,6 @@ PlaceholderMesh::PlaceholderMesh() { } PlaceholderMesh::~PlaceholderMesh() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(rid); } diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index 8afb0563b2..2ea357d814 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -365,5 +365,6 @@ MultiMesh::MultiMesh() { } MultiMesh::~MultiMesh() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(multimesh); } diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp index b77430c154..a07a8ac7cd 100644 --- a/scene/resources/particle_process_material.cpp +++ b/scene/resources/particle_process_material.cpp @@ -1894,6 +1894,7 @@ ParticleProcessMaterial::ParticleProcessMaterial() : } ParticleProcessMaterial::~ParticleProcessMaterial() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); MutexLock lock(material_mutex); if (shader_map.has(current_key)) { diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 54d3676c15..aeb62d6709 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -340,6 +340,7 @@ PrimitiveMesh::PrimitiveMesh() { } PrimitiveMesh::~PrimitiveMesh() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(mesh); } diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 48ec084b02..c6621ce482 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -208,6 +208,7 @@ Shader::Shader() { } Shader::~Shader() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(shader); } diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp index 735134e27b..32ce0abf7a 100644 --- a/scene/resources/sky.cpp +++ b/scene/resources/sky.cpp @@ -106,5 +106,6 @@ Sky::Sky() { } Sky::~Sky() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(sky); } diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 48eaf98aa3..0685ff0992 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -324,6 +324,7 @@ ImageTexture::ImageTexture() {} ImageTexture::~ImageTexture() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(texture); } } @@ -630,6 +631,7 @@ PortableCompressedTexture2D::PortableCompressedTexture2D() {} PortableCompressedTexture2D::~PortableCompressedTexture2D() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(texture); } } @@ -1041,6 +1043,7 @@ CompressedTexture2D::CompressedTexture2D() {} CompressedTexture2D::~CompressedTexture2D() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(texture); } } @@ -1225,6 +1228,7 @@ ImageTexture3D::ImageTexture3D() { ImageTexture3D::~ImageTexture3D() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(texture); } } @@ -1386,6 +1390,7 @@ CompressedTexture3D::CompressedTexture3D() {} CompressedTexture3D::~CompressedTexture3D() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(texture); } } @@ -1911,6 +1916,7 @@ CurveTexture::CurveTexture() {} CurveTexture::~CurveTexture() { if (_texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(_texture); } } @@ -2109,6 +2115,7 @@ CurveXYZTexture::CurveXYZTexture() {} CurveXYZTexture::~CurveXYZTexture() { if (_texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(_texture); } } @@ -2121,6 +2128,7 @@ GradientTexture1D::GradientTexture1D() { GradientTexture1D::~GradientTexture1D() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(texture); } } @@ -2263,6 +2271,7 @@ GradientTexture2D::GradientTexture2D() { GradientTexture2D::~GradientTexture2D() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(texture); } } @@ -2521,6 +2530,7 @@ void ProxyTexture::set_base(const Ref<Texture2D> &p_texture) { base = p_texture; if (base.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); if (proxy_ph.is_valid()) { RS::get_singleton()->texture_proxy_update(proxy, base->get_rid()); RS::get_singleton()->free(proxy_ph); @@ -2571,6 +2581,7 @@ ProxyTexture::ProxyTexture() { } ProxyTexture::~ProxyTexture() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); if (proxy_ph.is_valid()) { RS::get_singleton()->free(proxy_ph); } @@ -2828,6 +2839,7 @@ AnimatedTexture::AnimatedTexture() { } AnimatedTexture::~AnimatedTexture() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(proxy); RS::get_singleton()->free(proxy_ph); } @@ -3031,6 +3043,7 @@ ImageTextureLayered::ImageTextureLayered(LayeredType p_layered_type) { ImageTextureLayered::~ImageTextureLayered() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(texture); } } @@ -3198,6 +3211,7 @@ CompressedTextureLayered::CompressedTextureLayered(LayeredType p_type) { CompressedTextureLayered::~CompressedTextureLayered() { if (texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(texture); } } @@ -3353,6 +3367,7 @@ CameraTexture::CameraTexture() {} CameraTexture::~CameraTexture() { if (_texture.is_valid()) { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RenderingServer::get_singleton()->free(_texture); } } @@ -3394,6 +3409,7 @@ PlaceholderTexture2D::PlaceholderTexture2D() { } PlaceholderTexture2D::~PlaceholderTexture2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(rid); } @@ -3441,6 +3457,7 @@ PlaceholderTexture3D::PlaceholderTexture3D() { rid = RS::get_singleton()->texture_3d_placeholder_create(); } PlaceholderTexture3D::~PlaceholderTexture3D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(rid); } @@ -3499,5 +3516,6 @@ PlaceholderTextureLayered::PlaceholderTextureLayered(LayeredType p_type) { rid = RS::get_singleton()->texture_2d_layered_placeholder_create(RS::TextureLayeredType(layered_type)); } PlaceholderTextureLayered::~PlaceholderTextureLayered() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); RS::get_singleton()->free(rid); } diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 75deb1e60b..85ce47f06c 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -89,6 +89,9 @@ World2D::World2D() { } World2D::~World2D() { + ERR_FAIL_NULL(RenderingServer::get_singleton()); + ERR_FAIL_NULL(PhysicsServer2D::get_singleton()); + ERR_FAIL_NULL(NavigationServer2D::get_singleton()); RenderingServer::get_singleton()->free(canvas); PhysicsServer2D::get_singleton()->free(space); NavigationServer2D::get_singleton()->free(navigation_map); diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp index ae8c9a182f..8808da95d7 100644 --- a/scene/resources/world_3d.cpp +++ b/scene/resources/world_3d.cpp @@ -157,6 +157,9 @@ World3D::World3D() { } World3D::~World3D() { + ERR_FAIL_NULL(PhysicsServer3D::get_singleton()); + ERR_FAIL_NULL(RenderingServer::get_singleton()); + ERR_FAIL_NULL(NavigationServer3D::get_singleton()); PhysicsServer3D::get_singleton()->free(space); RenderingServer::get_singleton()->free(scenario); NavigationServer3D::get_singleton()->free(navigation_map); |