From eb2deabffe7cea3f584ce152781445714cda0ff9 Mon Sep 17 00:00:00 2001 From: BrunoSXS Date: Sat, 23 Oct 2021 17:30:18 -0300 Subject: Fixes a game crash caused by instantiating Camera2D and sending a notification from it before adding it to the tree. --- scene/2d/camera_2d.cpp | 1 + scene/main/canvas_item.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 8195d98f55..a6362ab0d5 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -232,6 +232,7 @@ void Camera2D::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { + ERR_FAIL_COND(!is_inside_tree()); if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) { viewport = custom_viewport; } else { diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 916833c9a7..232c522a47 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -274,6 +274,7 @@ void CanvasItem::_exit_canvas() { void CanvasItem::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { + ERR_FAIL_COND(!is_inside_tree()); _update_texture_filter_changed(false); _update_texture_repeat_changed(false); -- cgit v1.2.3