summaryrefslogtreecommitdiff
path: root/bin/offline.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-03-15 15:53:42 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-03-15 15:53:42 -0700
commitdef2c804e522dde6bd32fa845d6343530036722c (patch)
tree1dea623433a34bde5091c64380f3624da82e61a5 /bin/offline.cpp
parent9494fa72532f54e54a8b905acde7e188f4bb003b (diff)
downloadqtlocation-mapboxgl-def2c804e522dde6bd32fa845d6343530036722c.tar.gz
[test] Fix crash in offline binary
Diffstat (limited to 'bin/offline.cpp')
-rw-r--r--bin/offline.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/bin/offline.cpp b/bin/offline.cpp
index 68b36529d4..ddad1fe41f 100644
--- a/bin/offline.cpp
+++ b/bin/offline.cpp
@@ -55,16 +55,8 @@ int main(int argc, char *argv[]) {
using namespace mbgl;
util::RunLoop loop;
-
- static DefaultFileSource fileSource(output, ".");
- static std::unique_ptr<OfflineRegion> region;
-
- std::signal(SIGINT, [] (int) {
- if (region) {
- std::cout << "Stopping download... ";
- fileSource.setOfflineRegionDownloadState(*region, OfflineRegionDownloadState::Inactive);
- }
- });
+ DefaultFileSource fileSource(output, ".");
+ std::unique_ptr<OfflineRegion> region;
fileSource.setAccessToken(token);
@@ -122,6 +114,15 @@ int main(int argc, char *argv[]) {
SystemTimePoint start;
};
+ static auto stop = [&] {
+ if (region) {
+ std::cout << "Stopping download... ";
+ fileSource.setOfflineRegionDownloadState(*region, OfflineRegionDownloadState::Inactive);
+ }
+ };
+
+ std::signal(SIGINT, [] (int) { stop(); });
+
fileSource.createOfflineRegion(definition, metadata, [&] (std::exception_ptr error, optional<OfflineRegion> region_) {
if (error) {
std::cerr << "Error creating region: " << util::toString(error) << std::endl;