Fix notification thread guards

This commit is contained in:
bitsawer
2023-08-18 13:32:53 +03:00
parent 57a6813bb8
commit 12a2177967
3 changed files with 22 additions and 5 deletions

View File

@ -424,14 +424,17 @@ Point2 Node2D::to_global(Point2 p_local) const {
}
void Node2D::_notification(int p_notification) {
ERR_THREAD_GUARD;
switch (p_notification) {
case NOTIFICATION_ENTER_TREE: {
ERR_MAIN_THREAD_GUARD;
if (get_viewport()) {
get_parent()->connect(SNAME("child_order_changed"), callable_mp(get_viewport(), &Viewport::gui_set_root_order_dirty), CONNECT_REFERENCE_COUNTED);
}
} break;
case NOTIFICATION_EXIT_TREE: {
ERR_MAIN_THREAD_GUARD;
if (get_viewport()) {
get_parent()->disconnect(SNAME("child_order_changed"), callable_mp(get_viewport(), &Viewport::gui_set_root_order_dirty));
}