From 53e237dfe4aa550fa52a1187d1b19e7b5ec555eb Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 31 Jan 2016 15:09:52 -0300 Subject: -Fix crash opening and closing the scene, closes #3491 --- scene/3d/camera.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 3e78fef147..01163e40e8 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -213,8 +213,7 @@ void Camera::_notification(int p_what) { case NOTIFICATION_ENTER_WORLD: { - bool first_camera = get_viewport()->cameras.size()==0; - get_viewport()->cameras.insert(this); + bool first_camera = get_viewport()->_camera_add(this); if (!get_tree()->is_node_being_edited(this) && (current || first_camera)) make_current(); @@ -236,7 +235,7 @@ void Camera::_notification(int p_what) { } } - get_viewport()->cameras.erase(this); + get_viewport()->_camera_remove(this); } break; @@ -304,7 +303,7 @@ void Camera::make_current() { if (!is_inside_tree()) return; - get_viewport()->_set_camera(this); + get_viewport()->_camera_set(this); //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,camera_group,"_camera_make_current",this); } @@ -319,20 +318,8 @@ void Camera::clear_current() { return; if (get_viewport()->get_camera()==this) { - get_viewport()->_set_camera(NULL); - //a group is used beause this needs to be in order to be deterministic - - for (Set::Element *E=get_viewport()->cameras.front();E;E=E->next()) { - - if (this==E->get()) - continue; - if (!E->get()->is_inside_tree()) - continue; - if (get_viewport()->get_camera()!=NULL) - return; - - E->get()->make_current(); - } + get_viewport()->_camera_set(NULL); + get_viewport()->_camera_make_next_current(this); } } -- cgit v1.2.3