diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-10-27 12:32:50 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-10-27 12:32:50 -0400 |
commit | 54b3741cf1550e6e8e004da62930791cc09c8c05 (patch) | |
tree | 303d979856c31325902fd8ac65a060215e33f93d | |
parent | af9f317c251a0a1adfeaad8dd983ab602cf93070 (diff) | |
parent | 6695d5249d495e30c7689a29d012d5a8098007ab (diff) | |
download | qtlocation-mapboxgl-54b3741cf1550e6e8e004da62930791cc09c8c05.tar.gz |
Merge pull request #505 from mapbox/fix-libuv-0.11
Fix compiling with libuv 0.11
-rw-r--r-- | include/mbgl/map/map.hpp | 6 | ||||
-rw-r--r-- | include/mbgl/util/uv_detail.hpp | 2 | ||||
m--------- | ios/mapbox-gl-cocoa | 0 | ||||
-rw-r--r-- | src/map/map.cpp | 31 |
4 files changed, 17 insertions, 22 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index ab9775a8c9..bc67e5b35b 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -146,15 +146,9 @@ public: private: // uv async callbacks -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 - static void render(uv_async_t *async, int status); - static void terminate(uv_async_t *async, int status); - static void cleanup(uv_async_t *async, int status); -#else static void render(uv_async_t *async); static void terminate(uv_async_t *async); static void cleanup(uv_async_t *async); -#endif // Setup void setup(); diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index b4b41f31af..3bbfa4ac5a 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -29,7 +29,7 @@ public: if (l == nullptr) { #else l = new uv_loop_t; - if (uv_loop_init(&l) != 0) { + if (uv_loop_init(l) != 0) { #endif throw std::runtime_error("failed to initialize loop"); } diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa -Subproject 2d8fa07ab7dc1ff93728e656bac4a82da423e8b +Subproject bba56f27fa747409ac9ea20cf77f470f59a415a diff --git a/src/map/map.cpp b/src/map/map.cpp index a7520b2517..2f0dceb427 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -91,15 +91,28 @@ void Map::start() { is_stopped = false; // Setup async notifications - uv_async_init(**loop, async_terminate.get(), terminate); + +// Iron out the differences between libuv 0.10 and 0.11 +#ifdef UV_ASYNC_CALLBACK +#error Cannot overwrite UV_ASYNC_CALLBACK +#endif +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +#define UV_ASYNC_CALLBACK(name) [](uv_async_t *a, int) { return Map::name(a); } +#else +#define UV_ASYNC_CALLBACK(name) name +#endif + + uv_async_init(**loop, async_terminate.get(), UV_ASYNC_CALLBACK(terminate)); async_terminate->data = this; - uv_async_init(**loop, async_render.get(), render); + uv_async_init(**loop, async_render.get(), UV_ASYNC_CALLBACK(render)); async_render->data = this; - uv_async_init(**loop, async_cleanup.get(), cleanup); + uv_async_init(**loop, async_cleanup.get(), UV_ASYNC_CALLBACK(cleanup)); async_cleanup->data = this; +#undef UV_ASYNC_CALLBACK + uv_thread_create(*thread, [](void *arg) { Map *map = static_cast<Map *>(arg); #ifndef NDEBUG @@ -198,11 +211,7 @@ void Map::cleanup() { } } -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 -void Map::cleanup(uv_async_t *async, int) { -#else void Map::cleanup(uv_async_t *async) { -#endif Map *map = static_cast<Map *>(async->data); map->painter.cleanup(); @@ -223,11 +232,7 @@ void Map::setReachability(bool reachable) { } } -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 -void Map::render(uv_async_t *async, int) { -#else void Map::render(uv_async_t *async) { -#endif Map *map = static_cast<Map *>(async->data); assert(uv_thread_self() == map->map_thread); @@ -247,11 +252,7 @@ void Map::render(uv_async_t *async) { } } -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 -void Map::terminate(uv_async_t *async, int) { -#else void Map::terminate(uv_async_t *async) { -#endif // Closes all open handles on the loop. This means that the loop will automatically terminate. Map *map = static_cast<Map *>(async->data); assert(uv_thread_self() == map->map_thread); |