summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/class_db.h4
-rw-r--r--core/method_bind.h10
-rw-r--r--core/object.cpp10
-rw-r--r--core/undo_redo.cpp4
4 files changed, 16 insertions, 12 deletions
diff --git a/core/class_db.h b/core/class_db.h
index 4129a74147..490deb7873 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -294,11 +294,11 @@ public:
}
template <class M>
- static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) {
+ static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
GLOBAL_LOCK_FUNCTION;
- MethodBind *bind = create_vararg_method_bind(p_method, p_info);
+ MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant);
ERR_FAIL_COND_V(!bind, NULL);
bind->set_name(p_name);
diff --git a/core/method_bind.h b/core/method_bind.h
index 754d9f70e6..1860d227f7 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -344,7 +344,7 @@ public:
return (instance->*call_method)(p_args, p_arg_count, r_error);
}
- void set_method_info(const MethodInfo &p_info) {
+ void set_method_info(const MethodInfo &p_info, bool p_return_nil_is_variant) {
set_argument_count(p_info.arguments.size());
#ifdef DEBUG_METHODS_ENABLED
@@ -364,7 +364,9 @@ public:
}
argument_types = at;
arguments = p_info;
- arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
+ if (p_return_nil_is_variant) {
+ arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
+ }
#endif
}
@@ -387,11 +389,11 @@ public:
};
template <class T>
-MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, int, Variant::CallError &), const MethodInfo &p_info) {
+MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, int, Variant::CallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) {
MethodBindVarArg<T> *a = memnew((MethodBindVarArg<T>));
a->set_method(p_method);
- a->set_method_info(p_info);
+ a->set_method_info(p_info, p_return_nil_is_variant);
return a;
}
diff --git a/core/object.cpp b/core/object.cpp
index 57fd730f7f..35ccc38d4e 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1517,9 +1517,11 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const
ERR_FAIL_NULL(p_to_object);
Signal *s = signal_map.getptr(p_signal);
- ERR_FAIL_COND_MSG(!s, "Nonexistent signal: " + p_signal + ".");
+ ERR_FAIL_COND_MSG(!s, vformat("Nonexistent signal '%s' in %s.", p_signal, to_string()));
- ERR_FAIL_COND_MSG(s->lock > 0, "Attempt to disconnect signal '" + p_signal + "' while in emission callback. Use CONNECT_DEFERRED (to be able to safely disconnect) or CONNECT_ONESHOT (for automatic disconnection) as connection flags.");
+ ERR_FAIL_COND_MSG(s->lock > 0,
+ vformat("Attempt to disconnect %s signal '%s' while in emission callback '%s' (in target %s). Use CONNECT_DEFERRED (to be able to safely disconnect) or CONNECT_ONESHOT (for automatic disconnection) as connection flags.",
+ to_string(), p_signal, p_to_method, p_to_object->to_string()));
Signal::Target target(p_to_object->get_instance_id(), p_to_method);
@@ -1686,7 +1688,7 @@ void Object::_bind_methods() {
mi.name = "emit_signal";
mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal"));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "emit_signal", &Object::_emit_signal, mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "emit_signal", &Object::_emit_signal, mi, varray(), false);
}
{
@@ -1702,7 +1704,7 @@ void Object::_bind_methods() {
mi.name = "call_deferred";
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_deferred", &Object::_call_deferred_bind, mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_deferred", &Object::_call_deferred_bind, mi, varray(), false);
}
ClassDB::bind_method(D_METHOD("set_deferred", "property", "value"), &Object::set_deferred);
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index 98a9db5d3b..5d1144e1f5 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -520,7 +520,7 @@ void UndoRedo::_bind_methods() {
mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object"));
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_do_method", &UndoRedo::_add_do_method, mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_do_method", &UndoRedo::_add_do_method, mi, varray(), false);
}
{
@@ -529,7 +529,7 @@ void UndoRedo::_bind_methods() {
mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object"));
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_undo_method", &UndoRedo::_add_undo_method, mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_undo_method", &UndoRedo::_add_undo_method, mi, varray(), false);
}
ClassDB::bind_method(D_METHOD("add_do_property", "object", "property", "value"), &UndoRedo::add_do_property);