From 8fcc74e2531f53b6e09584fb58022f852a32b26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 30 Sep 2014 17:28:42 +0200 Subject: fix headless tests --- common/headless_view.cpp | 4 ++ common/headless_view.hpp | 1 + include/mbgl/map/tile_data.hpp | 2 +- include/mbgl/util/uv-worker.h | 2 + src/map/map.cpp | 17 +++++- src/map/vector_tile_data.cpp | 16 +++--- src/storage/file_source.cpp | 3 +- src/storage/http_request.cpp | 14 ++++- src/storage/sqlite_store.cpp | 2 +- src/util/uv-worker.c | 28 +++++++--- test/fixtures/fixture_request.cpp | 115 ++++++++++++-------------------------- 11 files changed, 102 insertions(+), 102 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index ed00f48e82..ace41d38c0 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -163,6 +163,10 @@ HeadlessView::~HeadlessView() { #endif } +void HeadlessView::notify() { + // no-op +} + void HeadlessView::notify_map_change(mbgl::MapChange /*change*/, mbgl::timestamp /*delay*/) { // no-op } diff --git a/common/headless_view.hpp b/common/headless_view.hpp index a8ce4aa325..42f9c46da2 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -21,6 +21,7 @@ public: void resize(uint16_t width, uint16_t height, float pixelRatio); + void notify(); void notify_map_change(MapChange change, timestamp delay = 0); void make_active(); void swap(); diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp index 07cf19c5c8..823523679a 100644 --- a/include/mbgl/map/tile_data.hpp +++ b/include/mbgl/map/tile_data.hpp @@ -41,7 +41,7 @@ public: public: TileData(Tile::ID id, Map &map, const util::ptr &source); - ~TileData(); + virtual ~TileData(); void request(); void cancel(); diff --git a/include/mbgl/util/uv-worker.h b/include/mbgl/util/uv-worker.h index a9c9aff500..eff1169a2b 100644 --- a/include/mbgl/util/uv-worker.h +++ b/include/mbgl/util/uv-worker.h @@ -21,11 +21,13 @@ struct uv_worker_s { #ifndef NDEBUG unsigned long thread_id; #endif + uv_loop_t *loop; uv_messenger_t *msgr; uv_chan_t chan; const char *name; int count; uv_worker_close_cb close_cb; + int active; }; int uv_worker_init(uv_worker_t *worker, uv_loop_t *loop, int count, const char *name); diff --git a/src/map/map.cpp b/src/map/map.cpp index f71ecdb270..4b797ceae3 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -58,6 +58,15 @@ Map::~Map() { if (async) { stop(); } + + // Explicitly reset all pointers. + texturepool.reset(); + sprite.reset(); + spriteAtlas.reset(); + glyphStore.reset(); + glyphAtlas.reset(); + style.reset(); + fileSource.reset(); } uv::worker &Map::getWorker() { @@ -265,8 +274,14 @@ void Map::setStyleJSON(std::string newStyleJSON, const std::string &base) { // TODO: Make threadsafe. styleJSON.swap(newStyleJSON); sprite.reset(); - assert(style); + if (!style) { + style = std::make_shared