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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user