summaryrefslogtreecommitdiff
path: root/editor/editor_autoload_settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_autoload_settings.cpp')
-rw-r--r--editor/editor_autoload_settings.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 7210211d90..f44e1b7b14 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -315,8 +315,7 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) {
Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
RES res = ResourceLoader::load(p_path);
- ERR_EXPLAIN("Can't autoload: " + p_path);
- ERR_FAIL_COND_V(res.is_null(), NULL);
+ ERR_FAIL_COND_V_MSG(res.is_null(), NULL, "Can't autoload: " + p_path + ".");
Node *n = NULL;
if (res->is_class("PackedScene")) {
Ref<PackedScene> ps = res;
@@ -325,20 +324,17 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
Ref<Script> s = res;
StringName ibt = s->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
- ERR_EXPLAIN("Script does not inherit a Node: " + p_path);
- ERR_FAIL_COND_V(!valid_type, NULL);
+ ERR_FAIL_COND_V_MSG(!valid_type, NULL, "Script does not inherit a Node: " + p_path + ".");
Object *obj = ClassDB::instance(ibt);
- ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt));
- ERR_FAIL_COND_V(obj == NULL, NULL);
+ ERR_FAIL_COND_V_MSG(obj == NULL, NULL, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
n = Object::cast_to<Node>(obj);
n->set_script(s.get_ref_ptr());
}
- ERR_EXPLAIN("Path in autoload not a node or script: " + p_path);
- ERR_FAIL_COND_V(!n, NULL);
+ ERR_FAIL_COND_V_MSG(!n, NULL, "Path in autoload not a node or script: " + p_path + ".");
return n;
}
@@ -443,11 +439,11 @@ void EditorAutoloadSettings::update_autoload() {
}
if (info.in_editor) {
ERR_CONTINUE(!info.node);
- get_tree()->get_root()->remove_child(info.node);
+ get_tree()->get_root()->call_deferred("remove_child", info.node);
}
if (info.node) {
- memdelete(info.node);
+ info.node->queue_delete();
info.node = NULL;
}
}