From caf8e5e3396f7210c11757874e48af641f924c17 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 22 Apr 2022 18:15:31 +0800 Subject: [PATCH] Close FileAccess before accessing it with DirAccess --- core/io/resource_format_binary.cpp | 4 ++++ scene/resources/resource_format_text.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 8d4dbc3f734..b6988109c50 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1153,6 +1153,8 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons uint32_t ver_format = f->get_32(); if (ver_format < FORMAT_VERSION_CAN_RENAME_DEPS) { + fw.unref(); + { Ref da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->remove(p_path + ".depren"); @@ -1295,6 +1297,8 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons return ERR_CANT_CREATE; } + fw.unref(); + Ref da = DirAccess::create(DirAccess::ACCESS_RESOURCES); da->remove(p_path); da->rename(p_path + ".depren", p_path); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 4b0456681b6..b18456d464e 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -898,6 +898,8 @@ Error ResourceLoaderText::rename_dependencies(Ref p_f, const String return ERR_CANT_CREATE; } + fw.unref(); + Ref da = DirAccess::create(DirAccess::ACCESS_RESOURCES); da->remove(p_path); da->rename(p_path + ".depren", p_path);