From edbf1d0ea49517be80e514595fc71d7069423edb Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 22 Feb 2019 09:04:59 -0300 Subject: [PATCH] Check that area is inside tree besides checking that queries are flushed, fixes #26148 --- scene/2d/area_2d.cpp | 2 +- scene/3d/area.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 63c4758a34c..9e8bf62fc5e 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -426,7 +426,7 @@ bool Area2D::is_monitoring() const { void Area2D::set_monitorable(bool p_enable) { - if (locked || Physics2DServer::get_singleton()->is_flushing_queries()) { + if (locked || (is_inside_tree() && Physics2DServer::get_singleton()->is_flushing_queries())) { ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitorable\",true/false)"); } ERR_FAIL_COND(locked || Physics2DServer::get_singleton()->is_flushing_queries()); diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 99f43b12424..9e15a416b25 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -439,7 +439,7 @@ Array Area::get_overlapping_bodies() const { void Area::set_monitorable(bool p_enable) { - if (locked || PhysicsServer::get_singleton()->is_flushing_queries()) { + if (locked || (is_inside_tree() && PhysicsServer::get_singleton()->is_flushing_queries())) { ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitorable\",true/false)"); } ERR_FAIL_COND(locked || PhysicsServer::get_singleton()->is_flushing_queries());