diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-03-05 16:59:15 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-03-05 16:59:15 +0100 |
commit | 5037e00ed9333adb3dccdf1aa65c09162b6fabe1 (patch) | |
tree | 6526b4e8dbeb2bdf93deb52511fa4cff18061385 /linux | |
parent | 69a5c0e15fe6053323a4ef5e9cfd3c838458b841 (diff) | |
download | qtlocation-mapboxgl-5037e00ed9333adb3dccdf1aa65c09162b6fabe1.tar.gz |
add SIGINT handling
Diffstat (limited to 'linux')
-rw-r--r-- | linux/main.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/linux/main.cpp b/linux/main.cpp index 319dcf24bd..9923588084 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -2,6 +2,8 @@ #include <GLFW/glfw3.h> #include <llmr/platform/platform.hpp> +#include <signal.h> + #include "settings.hpp" #include "request.hpp" @@ -270,12 +272,32 @@ double time() { } } +void quit_handler(int s) { + if (mapView) { + fprintf(stderr, "waiting for quit...\n"); + glfwSetWindowShouldClose(mapView->window, true); + llmr::platform::restart(); + } else { + exit(0); + } +} int main() { + // sigint handling + struct sigaction sigIntHandler; + sigIntHandler.sa_handler = quit_handler; + sigemptyset(&sigIntHandler.sa_mask); + sigIntHandler.sa_flags = 0; + sigaction(SIGINT, &sigIntHandler, NULL); + + + // curl init curl_global_init(CURL_GLOBAL_ALL); llmr::platform::Request::initialize(); + + // main loop mapView = new MapView(); mapView->init(); int ret = mapView->run(); |