summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2014-12-03 21:57:55 +1100
committerLeith Bade <leith@mapbox.com>2014-12-03 21:57:55 +1100
commitf090d6b2642a4b28f9690c4724a2f702d82f4072 (patch)
tree83c04ce835897455fe0b570793c51edae5729265 /platform/android
parent8208dfaba34db13cb638edc5137ed532d272c16f (diff)
downloadqtlocation-mapboxgl-f090d6b2642a4b28f9690c4724a2f702d82f4072.tar.gz
Use uv::async and various other fixes
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/asset_request_baton_libzip.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/platform/android/asset_request_baton_libzip.cpp b/platform/android/asset_request_baton_libzip.cpp
index a492079c25..1d2f055bfa 100644
--- a/platform/android/asset_request_baton_libzip.cpp
+++ b/platform/android/asset_request_baton_libzip.cpp
@@ -5,18 +5,21 @@
#include <boost/make_unique.hpp>
+#include <cerrno>
+// NOTE a bug in the Android NDK breaks std::errno
+// See https://code.google.com/p/android/issues/detail?id=72349
+// After this is fixed change usage errno to std::errno
#include <zip.h>
namespace mbgl {
-void AssetRequestBaton::run(uv_async_t *async) {
- AssetRequestBaton *ptr = (AssetRequestBaton *)async->data;
- assert(ptr->thread_id == uv_thread_self());
+void AssetRequestBaton::run(AssetRequestBaton *ptr) {
+ assert(ptr->threadId == uv_thread_self());
if (ptr->canceled || !ptr->request) {
// Either the AssetRequest object has been destructed, or the
// request was canceled.
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -27,8 +30,8 @@ void AssetRequestBaton::run(uv_async_t *async) {
const int message_size = zip_error_to_str(nullptr, 0, error, errno);
const std::unique_ptr<char[]> message = boost::make_unique<char[]>(message_size);
zip_error_to_str(message.get(), 0, error, errno);
- notify_error(async, 500, message.get());
- cleanup(async);
+ notify_error(ptr, 500, message.get());
+ cleanup(ptr);
return;
}
@@ -38,10 +41,10 @@ void AssetRequestBaton::run(uv_async_t *async) {
// Opening the asset failed or was canceled. We already have an open file handle
// though, which we'll have to close.
zip_error_get(apk, &error, nullptr);
- notify_error(async, error == ZIP_ER_NOENT ? 404 : 500, zip_strerror(apk));
+ notify_error(ptr, error == ZIP_ER_NOENT ? 404 : 500, zip_strerror(apk));
zip_close(apk);
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -49,12 +52,12 @@ void AssetRequestBaton::run(uv_async_t *async) {
if ((zip_stat(apk, apk_file_path.c_str(), ZIP_FL_NOCASE, &stat) != 0) || ptr->canceled || !ptr->request) {
// Stating failed or was canceled. We already have an open file handle
// though, which we'll have to close.
- notify_error(async, 500, zip_strerror(apk));
+ notify_error(ptr, 500, zip_strerror(apk));
zip_fclose(apk_file);
apk_file = nullptr;
zip_close(apk);
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -63,12 +66,12 @@ void AssetRequestBaton::run(uv_async_t *async) {
if (static_cast<zip_uint64_t>(zip_fread(apk_file, reinterpret_cast<void *>(data.get()), stat.size)) != stat.size || ptr->canceled || !ptr->request) {
// Reading failed or was canceled. We already have an open file handle
// though, which we'll have to close.
- notify_error(async, 500, zip_file_strerror(apk_file));
+ notify_error(ptr, 500, zip_file_strerror(apk_file));
zip_fclose(apk_file);
apk_file = nullptr;
zip_close(apk);
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
return;
}
@@ -90,7 +93,7 @@ void AssetRequestBaton::run(uv_async_t *async) {
}
apk = nullptr;
- cleanup(async);
+ cleanup(ptr);
}
}