Merge pull request #68735 from dzil123/v3_pckpacker_error_spam

[3.x] Fix PCKPacker error spam
This commit is contained in:
Rémi Verschelde 2022-11-19 00:43:22 +01:00
commit 08a6aab661
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 0 deletions

View File

@ -86,6 +86,8 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
}; };
Error PCKPacker::add_file(const String &p_file, const String &p_src) { Error PCKPacker::add_file(const String &p_file, const String &p_src) {
ERR_FAIL_COND_V_MSG(!file, ERR_INVALID_PARAMETER, "File must be opened before use.");
FileAccess *f = FileAccess::open(p_src, FileAccess::READ); FileAccess *f = FileAccess::open(p_src, FileAccess::READ);
if (!f) { if (!f) {
return ERR_FILE_CANT_OPEN; return ERR_FILE_CANT_OPEN;
@ -165,6 +167,9 @@ Error PCKPacker::flush(bool p_verbose) {
} }
file->close(); file->close();
memdelete(file);
file = nullptr;
memdelete_arr(buf); memdelete_arr(buf);
return OK; return OK;