Fix crash when deleting Camera2D and Viewport assigned to it
This commit is contained in:
parent
df69945f1f
commit
0f18f225ee
1 changed files with 3 additions and 2 deletions
|
@ -259,12 +259,13 @@ void Camera2D::_notification(int p_what) {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
|
const bool viewport_valid = !custom_viewport || ObjectDB::get_instance(custom_viewport_id);
|
||||||
if (is_current()) {
|
if (is_current()) {
|
||||||
if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
|
if (viewport && viewport_valid) {
|
||||||
viewport->set_canvas_transform(Transform2D());
|
viewport->set_canvas_transform(Transform2D());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (viewport) {
|
if (viewport && viewport_valid) {
|
||||||
viewport->disconnect("size_changed", this, "_update_scroll");
|
viewport->disconnect("size_changed", this, "_update_scroll");
|
||||||
}
|
}
|
||||||
remove_from_group(group_name);
|
remove_from_group(group_name);
|
||||||
|
|
Loading…
Reference in a new issue