Allow signal connecting even if script is invalid (only when compiled with tools), fixes #17070
This commit is contained in:
parent
616b91b498
commit
3a93499f89
11 changed files with 33 additions and 4 deletions
|
@ -1443,8 +1443,20 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
|
|||
if (!s) {
|
||||
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal);
|
||||
//check in script
|
||||
if (!signal_is_valid && !script.is_null() && Ref<Script>(script)->has_script_signal(p_signal))
|
||||
signal_is_valid = true;
|
||||
if (!signal_is_valid && !script.is_null()) {
|
||||
|
||||
if (Ref<Script>(script)->has_script_signal(p_signal)) {
|
||||
signal_is_valid = true;
|
||||
}
|
||||
#ifdef TOOLS_ENABLED
|
||||
else {
|
||||
//allow connecting signals anyway if script is invalid, see issue #17070
|
||||
if (!Ref<Script>(script)->is_valid()) {
|
||||
signal_is_valid = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!signal_is_valid) {
|
||||
ERR_EXPLAIN("In Object of type '" + String(get_class()) + "': Attempt to connect nonexistent signal '" + p_signal + "' to method '" + p_to_object->get_class() + "." + p_to_method + "'");
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
virtual MethodInfo get_method_info(const StringName &p_method) const = 0;
|
||||
|
||||
virtual bool is_tool() const = 0;
|
||||
virtual bool is_valid() const = 0;
|
||||
|
||||
virtual ScriptLanguage *get_language() const = 0;
|
||||
|
||||
|
|
|
@ -294,6 +294,10 @@ MethodInfo NativeScript::get_method_info(const StringName &p_method) const {
|
|||
return MethodInfo();
|
||||
}
|
||||
|
||||
bool NativeScript::is_valid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NativeScript::is_tool() const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ public:
|
|||
virtual MethodInfo get_method_info(const StringName &p_method) const;
|
||||
|
||||
virtual bool is_tool() const;
|
||||
virtual bool is_valid() const;
|
||||
|
||||
virtual ScriptLanguage *get_language() const;
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ public:
|
|||
PropertyInfo get_property_info(const StringName &p_property) const;
|
||||
|
||||
bool is_tool() const { return _tool; }
|
||||
bool is_valid() const { return true; }
|
||||
|
||||
virtual ScriptLanguage *get_language() const;
|
||||
|
||||
|
|
|
@ -867,7 +867,6 @@ bool GDScript::has_script_signal(const StringName &p_signal) const {
|
|||
else if (base_cache.is_valid()) {
|
||||
return base_cache->has_script_signal(p_signal);
|
||||
}
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
bool is_valid() const { return valid; }
|
||||
virtual bool is_valid() const { return valid; }
|
||||
|
||||
const Map<StringName, Ref<GDScript> > &get_subclasses() const { return subclasses; }
|
||||
const Map<StringName, Variant> &get_constants() const { return constants; }
|
||||
|
|
|
@ -2571,6 +2571,10 @@ void CSharpScript::update_exports() {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool CSharpScript::is_valid() const {
|
||||
return true; //TODO return false if invalid
|
||||
}
|
||||
|
||||
bool CSharpScript::has_script_signal(const StringName &p_signal) const {
|
||||
if (_signals.has(p_signal))
|
||||
return true;
|
||||
|
|
|
@ -158,6 +158,8 @@ public:
|
|||
virtual void update_exports();
|
||||
|
||||
virtual bool is_tool() const { return tool; }
|
||||
virtual bool is_valid() const;
|
||||
|
||||
virtual Ref<Script> get_base_script() const;
|
||||
virtual ScriptLanguage *get_language() const;
|
||||
|
||||
|
|
|
@ -981,6 +981,10 @@ bool VisualScript::is_tool() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool VisualScript::is_valid() const {
|
||||
return true; //always valid
|
||||
}
|
||||
|
||||
ScriptLanguage *VisualScript::get_language() const {
|
||||
|
||||
return VisualScriptLanguage::singleton;
|
||||
|
|
|
@ -341,6 +341,7 @@ public:
|
|||
virtual Error reload(bool p_keep_state = false);
|
||||
|
||||
virtual bool is_tool() const;
|
||||
virtual bool is_valid() const;
|
||||
|
||||
virtual ScriptLanguage *get_language() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue