summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-03 12:22:24 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-03 12:22:24 +0100
commit1b634c06d08c99f176122331f697e6525a76bf01 (patch)
treeb4d51265754a7dd4b63c4fb394649f17ef3bad16 /modules
parent5638fcdd7109e9827bd4f8c05a886eff74bfc021 (diff)
parentea33001b95d57f7b400d78d4b20bef23293d9077 (diff)
Merge pull request #69972 from adamscott/add-server-checks-before-free
Add safety-checks before some servers `free()`
Diffstat (limited to 'modules')
-rw-r--r--modules/gridmap/editor/grid_map_editor_plugin.cpp1
-rw-r--r--modules/gridmap/grid_map.cpp9
-rw-r--r--modules/noise/noise_texture_2d.cpp1
3 files changed, 11 insertions, 0 deletions
diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp
index 89ef9ddd90..186e6a504f 100644
--- a/modules/gridmap/editor/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp
@@ -1405,6 +1405,7 @@ GridMapEditor::GridMapEditor() {
}
GridMapEditor::~GridMapEditor() {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
_clear_clipboard_data();
for (int i = 0; i < 3; i++) {
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index e396d77d86..d23d68ffba 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -796,6 +796,10 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
}
void GridMap::_octant_exit_world(const OctantKey &p_key) {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
+ ERR_FAIL_NULL(PhysicsServer3D::get_singleton());
+ ERR_FAIL_NULL(NavigationServer3D::get_singleton());
+
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
@@ -834,6 +838,10 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
}
void GridMap::_octant_clean_up(const OctantKey &p_key) {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
+ ERR_FAIL_NULL(PhysicsServer3D::get_singleton());
+ ERR_FAIL_NULL(NavigationServer3D::get_singleton());
+
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
@@ -1186,6 +1194,7 @@ Vector3 GridMap::_get_offset() const {
}
void GridMap::clear_baked_meshes() {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
for (int i = 0; i < baked_meshes.size(); i++) {
RS::get_singleton()->free(baked_meshes[i].instance);
}
diff --git a/modules/noise/noise_texture_2d.cpp b/modules/noise/noise_texture_2d.cpp
index 8c785d7591..1b6f1d7897 100644
--- a/modules/noise/noise_texture_2d.cpp
+++ b/modules/noise/noise_texture_2d.cpp
@@ -40,6 +40,7 @@ NoiseTexture2D::NoiseTexture2D() {
}
NoiseTexture2D::~NoiseTexture2D() {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
if (texture.is_valid()) {
RS::get_singleton()->free(texture);
}