Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1: Fixes two problems with Area2D and remove_child() #7934

Merged
merged 1 commit into from
Mar 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions scene/2d/area_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ void Area2D::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_CONTINUE(!node);

node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);

if (!E->get().in_tree)
continue;

Expand All @@ -367,8 +371,6 @@ void Area2D::_clear_monitoring() {

emit_signal(SceneStringNames::get_singleton()->body_exit,obj);

node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
}

}
Expand All @@ -388,6 +390,9 @@ void Area2D::_clear_monitoring() {
continue;
//ERR_CONTINUE(!node);

node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);

if (!E->get().in_tree)
continue;

Expand All @@ -397,9 +402,6 @@ void Area2D::_clear_monitoring() {
}

emit_signal(SceneStringNames::get_singleton()->area_exit,obj);

node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
}
}

Expand All @@ -411,8 +413,14 @@ void Area2D::_notification(int p_what) {

case NOTIFICATION_EXIT_TREE: {

monitoring_stored = monitoring;
set_enable_monitoring(false);
_clear_monitoring();
} break;
case NOTIFICATION_ENTER_TREE: {

set_enable_monitoring(monitoring_stored);
} break;
}

}
Expand Down Expand Up @@ -686,6 +694,7 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea
monitorable=false;
collision_mask=1;
layer_mask=1;
monitoring_stored = true;
set_enable_monitoring(true);
set_monitorable(true);
}
Expand Down
1 change: 1 addition & 0 deletions scene/2d/area_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Area2D : public CollisionObject2D {
uint32_t layer_mask;
int priority;
bool monitoring;
bool monitoring_stored;
bool monitorable;
bool locked;

Expand Down