Fix cases of resources destroyed too early

This commit is contained in:
Pedro J. Estébanez
2021-01-06 20:25:05 +01:00
parent 8158d17edf
commit 6fbe0a494b
9 changed files with 41 additions and 50 deletions

View File

@@ -1898,7 +1898,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
}
void FileSystemDock::_resource_created() {
Object *c = new_resource_dialog->instance_selected();
Variant c = new_resource_dialog->instance_selected();
ERR_FAIL_COND(!c);
Resource *r = Object::cast_to<Resource>(c);
@@ -1912,17 +1912,14 @@ void FileSystemDock::_resource_created() {
memdelete(node);
}
REF res(r);
editor->push_item(c);
RES current_res = RES(r);
editor->push_item(r);
String fpath = path;
if (!fpath.ends_with("/")) {
fpath = fpath.get_base_dir();
}
editor->save_resource_as(current_res, fpath);
editor->save_resource_as(RES(r), fpath);
}
void FileSystemDock::_search_changed(const String &p_text, const Control *p_from) {