aboutsummaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_function.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez2017-05-17 14:47:17 +0200
committerPedro J. Estébanez2017-05-17 14:47:17 +0200
commit7b192313b3141322858cef646f8f76cf5d0f4152 (patch)
tree31b262b936c23f3d45281ab184813a09127269e7 /modules/gdscript/gd_function.cpp
parentaa046a85dc791e07a243d63570987fbddb2f04c9 (diff)
downloadgodot-7b192313b3141322858cef646f8f76cf5d0f4152.tar.gz
godot-7b192313b3141322858cef646f8f76cf5d0f4152.tar.zst
godot-7b192313b3141322858cef646f8f76cf5d0f4152.zip
Add extended check option to GDFunctionState::is_valid()
Diffstat (limited to 'modules/gdscript/gd_function.cpp')
-rw-r--r--modules/gdscript/gd_function.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index 91c547806..85dd9bf8f 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -1362,9 +1362,21 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
return ret;
}
-bool GDFunctionState::is_valid() const {
+bool GDFunctionState::is_valid(bool p_extended_check) const {
- return function != NULL;
+ if (function == NULL)
+ return false;
+
+ if (p_extended_check) {
+ //class instance gone?
+ if (state.instance_id && !ObjectDB::get_instance(state.instance_id))
+ return false;
+ //script gone?
+ if (state.script_id && !ObjectDB::get_instance(state.script_id))
+ return false;
+ }
+
+ return true;
}
Variant GDFunctionState::resume(const Variant &p_arg) {
@@ -1393,7 +1405,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
void GDFunctionState::_bind_methods() {
ObjectTypeDB::bind_method(_MD("resume:Variant", "arg"), &GDFunctionState::resume, DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("is_valid"), &GDFunctionState::is_valid);
+ ObjectTypeDB::bind_method(_MD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false));
ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback"));
}