main: quit on SIGINT
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Wed, 2 Jan 2013 23:19:57 +0000 (17:19 -0600)
committerUwe Hermann <uwe@hermann-uwe.de>
Wed, 20 Feb 2013 09:36:46 +0000 (10:36 +0100)
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
main.cpp

index a7ab89fbf7422ada41d7050ac57715ce33f7f05d..54a69fd75550eb3485861bd471d27f6e2d6497a7 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -34,6 +34,8 @@ extern "C" {
 
 #include "config.h"
 
+// Global pointer to our QApplication
+QApplication *g_app = NULL;
 void usage()
 {
        fprintf(stderr,
@@ -52,10 +54,11 @@ void usage()
 void sigint(int param)
 {
        (void) param;
-       
+
        qDebug("pv: Recieved SIGINT");
-       
-       /* TODO: Handle SIGINT */
+
+       if (g_app)
+               g_app->quit();
 }
 
 int main(int argc, char *argv[])
@@ -67,6 +70,8 @@ int main(int argc, char *argv[])
        signal (SIGINT, sigint);
 
        QApplication a(argc, argv);
+       // Now we have an application to populate our global pointer
+       g_app = &a;
 
        // Set some application metadata
        QApplication::setApplicationVersion(PV_VERSION_STRING);