mirror of
https://github.com/godotengine/godot.git
synced 2025-10-31 21:51:22 +00:00
Make FileAccess and DirAccess classes reference counted.
This commit is contained in:
parent
ca9372622f
commit
9381acb6a4
193 changed files with 1122 additions and 1776 deletions
|
|
@ -197,10 +197,7 @@ void HTTPRequest::cancel_request() {
|
|||
thread.wait_to_finish();
|
||||
}
|
||||
|
||||
if (file) {
|
||||
memdelete(file);
|
||||
file = nullptr;
|
||||
}
|
||||
file = Ref<FileAccess>();
|
||||
client->close();
|
||||
body.clear();
|
||||
got_response = false;
|
||||
|
|
@ -365,7 +362,7 @@ bool HTTPRequest::_update_connection() {
|
|||
|
||||
if (!download_to_file.is_empty()) {
|
||||
file = FileAccess::open(download_to_file, FileAccess::WRITE);
|
||||
if (!file) {
|
||||
if (file.is_null()) {
|
||||
call_deferred(SNAME("_request_done"), RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, PackedByteArray());
|
||||
return true;
|
||||
}
|
||||
|
|
@ -381,7 +378,7 @@ bool HTTPRequest::_update_connection() {
|
|||
|
||||
if (chunk.size()) {
|
||||
downloaded.add(chunk.size());
|
||||
if (file) {
|
||||
if (file.is_valid()) {
|
||||
const uint8_t *r = chunk.ptr();
|
||||
file->store_buffer(r, chunk.size());
|
||||
if (file->get_error() != OK) {
|
||||
|
|
@ -642,9 +639,3 @@ HTTPRequest::HTTPRequest() {
|
|||
timer->connect("timeout", callable_mp(this, &HTTPRequest::_timeout));
|
||||
add_child(timer);
|
||||
}
|
||||
|
||||
HTTPRequest::~HTTPRequest() {
|
||||
if (file) {
|
||||
memdelete(file);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue