Browse Source

Fix unexpected crashes in `notification`

(cherry picked from commit 924c2078dae69e73032af04e96200f44187d2c8d)
Zae 3 years ago
parent
commit
a1b282cc16
3 changed files with 4 additions and 0 deletions
  1. 1 0
      scene/2d/collision_polygon_2d.cpp
  2. 2 0
      scene/2d/collision_shape_2d.cpp
  3. 1 0
      scene/2d/ray_cast_2d.cpp

+ 1 - 0
scene/2d/collision_polygon_2d.cpp

@@ -133,6 +133,7 @@ void CollisionPolygon2D::_notification(int p_what) {
 		} break;
 
 		case NOTIFICATION_DRAW: {
+			ERR_FAIL_COND(!is_inside_tree());
 			if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
 				break;
 			}

+ 2 - 0
scene/2d/collision_shape_2d.cpp

@@ -94,6 +94,8 @@ void CollisionShape2D::_notification(int p_what) {
 
 		} break;
 		case NOTIFICATION_DRAW: {
+			ERR_FAIL_COND(!is_inside_tree());
+
 			if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
 				break;
 			}

+ 1 - 0
scene/2d/ray_cast_2d.cpp

@@ -155,6 +155,7 @@ void RayCast2D::_notification(int p_what) {
 		} break;
 
 		case NOTIFICATION_DRAW: {
+			ERR_FAIL_COND(!is_inside_tree());
 			if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
 				break;
 			}