summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-04-20 10:25:39 +0200
committerGitHub <noreply@github.com>2019-04-20 10:25:39 +0200
commitb3d2584960dd7ede84591996ac1f880dd87106fe (patch)
treea64e82c544fd997b255fd2a5a8d9748e0bd43101
parentc1444ebeaf4a17e5c3489dded45ae71f96341bd3 (diff)
parent20b0046945bfe55591c370e32f4928f7cbeb45e6 (diff)
Merge pull request #28210 from hpvb/fix-28134
Object::script may not be a valid Ref<Script>
-rw-r--r--core/object.cpp5
-rw-r--r--editor/editor_inspector.cpp22
-rw-r--r--scene/main/node.cpp2
3 files changed, 18 insertions, 11 deletions
diff --git a/core/object.cpp b/core/object.cpp
index 03a11b8ca3..039f556c87 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1366,7 +1366,10 @@ Array Object::_get_incoming_connections() const {
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
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);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index c705f9af2b..b630442ad6 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -470,10 +470,12 @@ bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringNam
if (!has_revert && !p_object->get_script().is_null()) {
Ref<Script> scr = p_object->get_script();
- Variant orig_value;
- if (scr->get_property_default_value(p_property, orig_value)) {
- if (orig_value != p_object->get(p_property)) {
- has_revert = true;
+ if (scr.is_valid()) {
+ Variant orig_value;
+ if (scr->get_property_default_value(p_property, orig_value)) {
+ 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()) {
Ref<Script> scr = object->get_script();
- Variant orig_value;
- if (scr->get_property_default_value(property, orig_value)) {
- emit_changed(property, orig_value);
- update_property();
- return;
+ if (scr.is_valid()) {
+ Variant orig_value;
+ if (scr->get_property_default_value(property, orig_value)) {
+ emit_changed(property, orig_value);
+ update_property();
+ return;
+ }
}
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 5f9c187e0b..cbe700c826 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2421,7 +2421,7 @@ void Node::_replace_connections_target(Node *p_new_target) {
if (c.flags & CONNECT_PERSIST) {
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_CONTINUE(!valid);
c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags);