summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-10-22 12:30:20 +0200
committerGitHub <noreply@github.com>2021-10-22 12:30:20 +0200
commit119f79079bc9e380718a539221c3a236a7f16d88 (patch)
tree4e017247da405be038a0ea5f5a80a780d657548c
parentb4562106bb668e3de7ca93624c58378d81676981 (diff)
parent497b00a93705c30148601bfe6cb8a0915e0cad5d (diff)
Merge pull request #54113 from skimmedsquare/canvas-layer-notification-crash-54098
-rw-r--r--scene/main/canvas_layer.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 4540e42b4c..26bff4494b 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -128,7 +128,7 @@ void CanvasLayer::_notification(int p_what) {
} else {
vp = Node::get_viewport();
}
- ERR_FAIL_COND(!vp);
+ ERR_FAIL_NULL_MSG(vp, "Viewport is not initialized.");
vp->_canvas_layer_add(this);
viewport = vp->get_viewport_rid();
@@ -140,6 +140,8 @@ void CanvasLayer::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
+ ERR_FAIL_NULL_MSG(vp, "Viewport is not initialized.");
+
vp->_canvas_layer_remove(this);
RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
viewport = RID();
@@ -160,6 +162,8 @@ Size2 CanvasLayer::get_viewport_size() const {
return Size2(1, 1);
}
+ ERR_FAIL_NULL_V_MSG(vp, Size2(1, 1), "Viewport is not initialized.");
+
Rect2 r = vp->get_visible_rect();
return r.size;
}
@@ -169,7 +173,7 @@ RID CanvasLayer::get_viewport() const {
}
void CanvasLayer::set_custom_viewport(Node *p_viewport) {
- ERR_FAIL_NULL(p_viewport);
+ ERR_FAIL_NULL_MSG(p_viewport, "Cannot set viewport to nullptr.");
if (is_inside_tree()) {
vp->_canvas_layer_remove(this);
RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas);