summaryrefslogtreecommitdiff
path: root/test/headless
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-04-30 14:48:04 -0400
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-05-01 18:25:41 -0400
commit5475f3138bea139dd86a75ddd774051889a398c7 (patch)
tree5a71f0ec4ebfc8c01bc0cabb0eb11357c11299b1 /test/headless
parentb713930c7f08b511f1cf6dbd79e803840de71889 (diff)
downloadqtlocation-mapboxgl-5475f3138bea139dd86a75ddd774051889a398c7.tar.gz
Fix potential crash
The promise could be deallocated before promise.set_value() had returned, which apparently caused an invalid read on some implementations. By moving the promise declaration up the stack, we ensure that the map is deallocated first, and therefore the map thread is joined, before the promise is deallocated.
Diffstat (limited to 'test/headless')
-rw-r--r--test/headless/headless.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/headless/headless.cpp b/test/headless/headless.cpp
index 5a76743774..38fbf63b59 100644
--- a/test/headless/headless.cpp
+++ b/test/headless/headless.cpp
@@ -142,6 +142,8 @@ TEST_P(HeadlessTest, render) {
}
}
+ std::promise<void> promise;
+
HeadlessView view(display, width, height, pixelRatio);
DefaultFileSource fileSource(nullptr);
Map map(view, fileSource, MapMode::Still);
@@ -152,8 +154,6 @@ TEST_P(HeadlessTest, render) {
map.setLatLngZoom(mbgl::LatLng(latitude, longitude), zoom);
map.setBearing(bearing);
- std::promise<void> promise;
-
map.renderStill([&](std::unique_ptr<const StillImage> image) {
const std::string png = util::compress_png(image->width, image->height, image->pixels.get());
util::write_file("test/suite/tests/" + base + "/" + name + "/actual.png", png);