summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorAdam Scott <ascott.ca@gmail.com>2022-12-12 12:42:37 -0500
committerAdam Scott <ascott.ca@gmail.com>2022-12-29 16:23:38 -0500
commitea33001b95d57f7b400d78d4b20bef23293d9077 (patch)
tree71ac58a0294e7417e42601cd46fccaac4bcbbe2e /scene/resources
parenta75493091823020d858fabadbfa5994da0d658cb (diff)
Add safety-checks before some servers `free()`
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/camera_attributes.cpp1
-rw-r--r--scene/resources/canvas_item_material.cpp2
-rw-r--r--scene/resources/environment.cpp1
-rw-r--r--scene/resources/fog_material.cpp1
-rw-r--r--scene/resources/immediate_mesh.cpp1
-rw-r--r--scene/resources/material.cpp2
-rw-r--r--scene/resources/mesh.cpp2
-rw-r--r--scene/resources/multimesh.cpp1
-rw-r--r--scene/resources/particle_process_material.cpp1
-rw-r--r--scene/resources/primitive_meshes.cpp1
-rw-r--r--scene/resources/shader.cpp1
-rw-r--r--scene/resources/sky.cpp1
-rw-r--r--scene/resources/texture.cpp18
-rw-r--r--scene/resources/world_2d.cpp3
-rw-r--r--scene/resources/world_3d.cpp3
15 files changed, 39 insertions, 0 deletions
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 18915e294e..9368812230 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);