Przeglądaj źródła

Fixes a game crash caused by instantiating Camera2D and sending a notification from it before adding it to the tree.

(cherry picked from commit eb2deabffe7cea3f584ce152781445714cda0ff9)
BrunoSXS 3 lat temu
rodzic
commit
8fd0fe3d20
2 zmienionych plików z 2 dodań i 0 usunięć
  1. 1 0
      scene/2d/camera_2d.cpp
  2. 1 0
      scene/2d/canvas_item.cpp

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

@@ -245,6 +245,7 @@ void Camera2D::_notification(int p_what) {
 
 		} break;
 		case NOTIFICATION_ENTER_TREE: {
+			ERR_FAIL_COND(!is_inside_tree());
 			canvas = get_canvas();
 
 			_setup_viewport();

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

@@ -554,6 +554,7 @@ void CanvasItem::_exit_canvas() {
 void CanvasItem::_notification(int p_what) {
 	switch (p_what) {
 		case NOTIFICATION_ENTER_TREE: {
+			ERR_FAIL_COND(!is_inside_tree());
 			first_draw = true;
 			if (get_parent()) {
 				CanvasItem *ci = Object::cast_to<CanvasItem>(get_parent());