summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-21 10:12:43 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-21 11:15:52 -0700
commit51b53723b9f8d0a1c76474d17b2d89d492316fd4 (patch)
tree3911831a874e90efed44c86a4f4bd4099a82777a
parent41efb3be2854a806512c70cf8e20a900c969687d (diff)
downloadqtlocation-mapboxgl-upstream/node-fixes.tar.gz
[node] Reset Style::Impl::lastError when loading a new styleupstream/node-fixes
-rw-r--r--platform/node/test/js/request.test.js51
-rw-r--r--src/mbgl/style/style_impl.cpp2
2 files changed, 53 insertions, 0 deletions
diff --git a/platform/node/test/js/request.test.js b/platform/node/test/js/request.test.js
index ec2b084f4e..4f8d1cabb0 100644
--- a/platform/node/test/js/request.test.js
+++ b/platform/node/test/js/request.test.js
@@ -114,3 +114,54 @@ test(`render ignores request functions calling the callback a second time`, func
});
});
+test(`render reports an error from loading the current style`, function(t) {
+ var map = new mbgl.Map({
+ request: function(req, callback) {
+ var data = mockfs.dataForRequest(req);
+ if (mockfs.source_vector === data) {
+ callback(new Error('message'));
+ } else {
+ callback(null, { data: data });
+ }
+ }
+ });
+ map.load(mockfs.style_vector);
+ map.render({ zoom: 16 }, function(err, pixels) {
+ t.assert(err);
+ t.assert(/message/.test(err.message));
+ t.assert(!pixels);
+
+ map.render({ zoom: 16 }, function(err, pixels) {
+ t.assert(err);
+ t.assert(/message/.test(err.message));
+ t.assert(!pixels);
+ t.end();
+ });
+ });
+});
+
+test(`render does not report an error from rendering a previous style`, function(t) {
+ var map = new mbgl.Map({
+ request: function(req, callback) {
+ var data = mockfs.dataForRequest(req);
+ if (mockfs.source_vector === data) {
+ callback(new Error('message'));
+ } else {
+ callback(null, { data: data });
+ }
+ }
+ });
+ map.load(mockfs.style_vector);
+ map.render({ zoom: 16 }, function(err, pixels) {
+ t.assert(err);
+ t.assert(/message/.test(err.message));
+ t.assert(!pixels);
+
+ map.load(mockfs.style_raster);
+ map.render({ zoom: 16 }, function(err, pixels) {
+ t.error(err);
+ t.assert(pixels);
+ t.end();
+ });
+ });
+});
diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp
index 9cc2588ca7..604af4be20 100644
--- a/src/mbgl/style/style_impl.cpp
+++ b/src/mbgl/style/style_impl.cpp
@@ -38,6 +38,7 @@ Style::Impl::Impl(Scheduler& scheduler_, FileSource& fileSource_, float pixelRat
Style::Impl::~Impl() = default;
void Style::Impl::loadJSON(const std::string& json_) {
+ lastError = nullptr;
observer->onStyleLoading();
url.clear();
@@ -45,6 +46,7 @@ void Style::Impl::loadJSON(const std::string& json_) {
}
void Style::Impl::loadURL(const std::string& url_) {
+ lastError = nullptr;
observer->onStyleLoading();
loaded = false;