Make memnew(RefCounted) return Ref, to force callers to take ownership of it through a reference.

This commit is contained in:
Lukas Tenbrink
2025-10-23 18:21:08 +02:00
parent 456bdea954
commit 05c33acbb1
58 changed files with 174 additions and 196 deletions
+3 -3
View File
@@ -2126,8 +2126,8 @@ Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
String path = ResourceLoader::path_remap(local_path);
TextFile *text_file = memnew(TextFile);
Ref<TextFile> text_res(text_file);
Ref<TextFile> text_file;
text_file.instantiate();
Error err = text_file->load_text(path);
ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Cannot load text file '" + path + "'.");
@@ -2143,7 +2143,7 @@ Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error
*r_error = OK;
}
return text_res;
return text_file;
}
Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_path) {