Object::script may not be a valid Ref<Script>
It appears that Object::script may be a valid ScriptInstance but not be castable to Ref<Script>. There were only 5 places in the code that made this assumption. This commit fixes that.
This commit is contained in:
parent
8e652a1400
commit
20b0046945
|
@ -1366,7 +1366,10 @@ Array Object::_get_incoming_connections() const {
|
||||||
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
|
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
|
||||||
|
|
||||||
if (!script.is_null()) {
|
if (!script.is_null()) {
|
||||||
Ref<Script>(script)->get_script_signal_list(p_signals);
|
Ref<Script> scr = script;
|
||||||
|
if (scr.is_valid()) {
|
||||||
|
scr->get_script_signal_list(p_signals);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassDB::get_signal_list(get_class_name(), p_signals);
|
ClassDB::get_signal_list(get_class_name(), p_signals);
|
||||||
|
|
|
@ -470,10 +470,12 @@ bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringNam
|
||||||
|
|
||||||
if (!has_revert && !p_object->get_script().is_null()) {
|
if (!has_revert && !p_object->get_script().is_null()) {
|
||||||
Ref<Script> scr = p_object->get_script();
|
Ref<Script> scr = p_object->get_script();
|
||||||
Variant orig_value;
|
if (scr.is_valid()) {
|
||||||
if (scr->get_property_default_value(p_property, orig_value)) {
|
Variant orig_value;
|
||||||
if (orig_value != p_object->get(p_property)) {
|
if (scr->get_property_default_value(p_property, orig_value)) {
|
||||||
has_revert = true;
|
if (orig_value != p_object->get(p_property)) {
|
||||||
|
has_revert = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -668,11 +670,13 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
|
|
||||||
if (!object->get_script().is_null()) {
|
if (!object->get_script().is_null()) {
|
||||||
Ref<Script> scr = object->get_script();
|
Ref<Script> scr = object->get_script();
|
||||||
Variant orig_value;
|
if (scr.is_valid()) {
|
||||||
if (scr->get_property_default_value(property, orig_value)) {
|
Variant orig_value;
|
||||||
emit_changed(property, orig_value);
|
if (scr->get_property_default_value(property, orig_value)) {
|
||||||
update_property();
|
emit_changed(property, orig_value);
|
||||||
return;
|
update_property();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2421,7 +2421,7 @@ void Node::_replace_connections_target(Node *p_new_target) {
|
||||||
|
|
||||||
if (c.flags & CONNECT_PERSIST) {
|
if (c.flags & CONNECT_PERSIST) {
|
||||||
c.source->disconnect(c.signal, this, c.method);
|
c.source->disconnect(c.signal, this, c.method);
|
||||||
bool valid = p_new_target->has_method(c.method) || p_new_target->get_script().is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.method);
|
bool valid = p_new_target->has_method(c.method) || Ref<Script>(p_new_target->get_script()).is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.method);
|
||||||
ERR_EXPLAIN("Attempt to connect signal \'" + c.source->get_class() + "." + c.signal + "\' to nonexistent method \'" + c.target->get_class() + "." + c.method + "\'");
|
ERR_EXPLAIN("Attempt to connect signal \'" + c.source->get_class() + "." + c.signal + "\' to nonexistent method \'" + c.target->get_class() + "." + c.method + "\'");
|
||||||
ERR_CONTINUE(!valid);
|
ERR_CONTINUE(!valid);
|
||||||
c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags);
|
c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags);
|
||||||
|
|
Loading…
Reference in New Issue