diff options
author | Adam Scott <ascott.ca@gmail.com> | 2022-12-12 12:42:37 -0500 |
---|---|---|
committer | Adam Scott <ascott.ca@gmail.com> | 2022-12-29 16:23:38 -0500 |
commit | ea33001b95d57f7b400d78d4b20bef23293d9077 (patch) | |
tree | 71ac58a0294e7417e42601cd46fccaac4bcbbe2e /scene/main | |
parent | a75493091823020d858fabadbfa5994da0d658cb (diff) |
Add safety-checks before some servers `free()`
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/canvas_item.cpp | 2 | ||||
-rw-r--r-- | scene/main/canvas_layer.cpp | 1 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 6 |
3 files changed, 9 insertions, 0 deletions
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); } |