mirror of
https://github.com/godotengine/godot.git
synced 2025-10-28 04:04:24 +00:00
Convert uses of DirAccess * to DirAccessRef to prevent memleaks
`DirAccess *` needs to be deleted manually, and this is often forgotten especially when doing early returns with `ERR_FAIL_COND`. `DirAccessRef` is deleted automatically when it goes out of scope. Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
This commit is contained in:
parent
259114e9e0
commit
768f9422bc
28 changed files with 154 additions and 259 deletions
|
|
@ -535,9 +535,8 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
|
|||
// Issue an error if "mv" failed to move the given resource to the trash can.
|
||||
if (err != OK || retval != 0) {
|
||||
ERR_PRINT("move_to_trash: Could not move the resource \"" + path + "\" to the trash can \"" + trash_path + "/files\"");
|
||||
DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
err = dir_access->rename(renamed_path, path);
|
||||
memdelete(dir_access);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename \"" + renamed_path + "\" back to its original name: \"" + path + "\"");
|
||||
return FAILED;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue