Fix unexpected crashes in notification
This commit is contained in:
parent
fe3d62f2dc
commit
924c2078da
4 changed files with 13 additions and 3 deletions
|
@ -131,6 +131,7 @@ void CollisionPolygon2D::_notification(int p_what) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_DRAW: {
|
case NOTIFICATION_DRAW: {
|
||||||
|
ERR_FAIL_COND(!is_inside_tree());
|
||||||
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
|
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,8 @@ void CollisionShape2D::_notification(int p_what) {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_DRAW: {
|
case NOTIFICATION_DRAW: {
|
||||||
|
ERR_FAIL_COND(!is_inside_tree());
|
||||||
|
|
||||||
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
|
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,7 @@ void RayCast2D::_notification(int p_what) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_DRAW: {
|
case NOTIFICATION_DRAW: {
|
||||||
|
ERR_FAIL_COND(!is_inside_tree());
|
||||||
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
|
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -637,7 +637,9 @@ void Control::_notification(int p_notification) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//is a regular root control or top_level
|
//is a regular root control or top_level
|
||||||
data.RI = get_viewport()->_gui_add_root_control(this);
|
Viewport *viewport = get_viewport();
|
||||||
|
ERR_FAIL_COND(!viewport);
|
||||||
|
data.RI = viewport->_gui_add_root_control(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.parent_canvas_item = get_parent_item();
|
data.parent_canvas_item = get_parent_item();
|
||||||
|
@ -646,7 +648,9 @@ void Control::_notification(int p_notification) {
|
||||||
data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed));
|
data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed));
|
||||||
} else {
|
} else {
|
||||||
//connect viewport
|
//connect viewport
|
||||||
get_viewport()->connect("size_changed", callable_mp(this, &Control::_size_changed));
|
Viewport *viewport = get_viewport();
|
||||||
|
ERR_FAIL_COND(!viewport);
|
||||||
|
viewport->connect("size_changed", callable_mp(this, &Control::_size_changed));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_EXIT_CANVAS: {
|
case NOTIFICATION_EXIT_CANVAS: {
|
||||||
|
@ -655,7 +659,9 @@ void Control::_notification(int p_notification) {
|
||||||
data.parent_canvas_item = nullptr;
|
data.parent_canvas_item = nullptr;
|
||||||
} else if (!is_set_as_top_level()) {
|
} else if (!is_set_as_top_level()) {
|
||||||
//disconnect viewport
|
//disconnect viewport
|
||||||
get_viewport()->disconnect("size_changed", callable_mp(this, &Control::_size_changed));
|
Viewport *viewport = get_viewport();
|
||||||
|
ERR_FAIL_COND(!viewport);
|
||||||
|
viewport->disconnect("size_changed", callable_mp(this, &Control::_size_changed));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.RI) {
|
if (data.RI) {
|
||||||
|
|
Loading…
Reference in a new issue