diff options
author | Leith Bade <leith@mapbox.com> | 2015-09-17 17:34:13 -0700 |
---|---|---|
committer | Leith Bade <leith@mapbox.com> | 2015-09-23 11:57:41 +1000 |
commit | 8cf927f6c423ad5e5ce9c8931002ee1c1dce1d9d (patch) | |
tree | e05585e9b5268d6d9d84f40f7503d8dfcfbda953 /platform | |
parent | db6a08d8caef8818032a89725340419f258d09ea (diff) | |
download | qtlocation-mapboxgl-8cf927f6c423ad5e5ce9c8931002ee1c1dce1d9d.tar.gz |
Improve handling of cancelled HTTP requests
Fix a memory leak of NativeMapView Java object
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/http_request_android.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/platform/android/http_request_android.cpp b/platform/android/http_request_android.cpp index 249cb731e9..5c5805906c 100644 --- a/platform/android/http_request_android.cpp +++ b/platform/android/http_request_android.cpp @@ -75,7 +75,8 @@ private: static const int connectionError = 0; static const int temporaryError = 1; - static const int permanentError = 1; + static const int permanentError = 2; + static const int canceledError = 3; }; // ------------------------------------------------------------------------------------------------- @@ -305,22 +306,26 @@ void HTTPAndroidRequest::onResponse(int code, std::string message, std::string e } void HTTPAndroidRequest::onFailure(int type, std::string message) { - if (!response) { - response = std::make_unique<Response>(); - } - - response->status = Response::Error; - response->message = message; - - switch (type) { - case connectionError: - status = ResponseStatus::ConnectionError; - - case temporaryError: - status = ResponseStatus::TemporaryError; + if (type != canceledError) { + if (!response) { + response = std::make_unique<Response>(); + } - default: - status = ResponseStatus::PermanentError; + response->status = Response::Error; + response->message = message; + + switch (type) { + case connectionError: + status = ResponseStatus::ConnectionError; + break; + case temporaryError: + status = ResponseStatus::TemporaryError; + break; + default: + status = ResponseStatus::PermanentError; + } + } else { + status = ResponseStatus::Canceled; } async.send(); |