summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshaderbeast <jd16581556@gmail.com>2019-09-01 01:25:22 +0200
committershaderbeast <jd16581556@gmail.com>2019-09-03 13:26:41 +0200
commit5e337b31ebcf4509e1cf4cb64b02908ade59df05 (patch)
treec221b3525d130ecc7823900a0f14321116752541
parent00aabec8bb598592b8a8702797b51fc9f6ca6169 (diff)
Added is_inside_tree() check in both Timer and Tween
Tween now throws error and doesnt even execute.
-rw-r--r--scene/animation/tween.cpp4
-rw-r--r--scene/gui/control.cpp4
-rwxr-xr-xscene/main/timer.cpp3
3 files changed, 7 insertions, 4 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 2609924f33..0f7d4466c8 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -783,10 +783,12 @@ float Tween::get_speed_scale() const {
}
bool Tween::start() {
+
+ ERR_FAIL_COND_V_MSG(!is_inside_tree(), false, "Tween was not added to the SceneTree!");
+
// Are there any pending updates?
if (pending_update != 0) {
// Start the tweens after deferring
- call_deferred("start");
return true;
}
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 034e9266f6..174c2fce7d 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2149,9 +2149,7 @@ bool Control::has_focus() const {
void Control::grab_focus() {
- if (!is_inside_tree()) {
- ERR_FAIL_COND(!is_inside_tree());
- }
+ ERR_FAIL_COND(!is_inside_tree());
if (data.focus_mode == FOCUS_NONE) {
WARN_PRINT("This control can't grab focus. Use set_focus_mode() to allow a control to get focus.");
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 03d46fd28d..14cc705edb 100755
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -107,6 +107,9 @@ bool Timer::has_autostart() const {
}
void Timer::start(float p_time) {
+
+ ERR_FAIL_COND_MSG(!is_inside_tree(), "Timer was not added to the SceneTree!");
+
if (p_time > 0) {
set_wait_time(p_time);
}