diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/offline.cpp | 21 |
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; |