Skip to content
Permalink
Browse files

Handle sigint to terminate qgis app immediately

  • Loading branch information
nyalldawson committed Mar 5, 2019
1 parent 620db06 commit 534ff68bbc20da17937c48a9fb168e6d41132577
Showing with 21 additions and 0 deletions.
  1. +3 −0 src/app/CMakeLists.txt
  2. +18 −0 src/app/main.cpp
@@ -1,4 +1,5 @@
ADD_SUBDIRECTORY(../../external/libdxfrw dwg/libdxfrw)
SUBDIRS(${CMAKE_SOURCE_DIR}/external/qt-unix-signals)

SET(QGIS_APP_SRCS
${CMAKE_SOURCE_DIR}/external/nmea/gmath.c
@@ -729,6 +730,7 @@ INCLUDE_DIRECTORIES(SYSTEM
${QWT_INCLUDE_DIR}
${QT_QTUITOOLS_INCLUDE_DIR}
${QSCINTILLA_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/external/qt-unix-signals
)
INCLUDE_DIRECTORIES(
../analysis/processing
@@ -882,6 +884,7 @@ IF(WIN32)
ENDIF(WIN32)

TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} qgis_native)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} QTSignal)

IF (APPLE)
SET_TARGET_PROPERTIES(${QGIS_APP_NAME} PROPERTIES
@@ -38,6 +38,8 @@
#include <cstdlib>
#include <cstdarg>

#include "sigwatch.h"

#ifdef WIN32
// Open files in binary mode
#include <fcntl.h> /* _O_BINARY */
@@ -1521,6 +1523,22 @@ int main( int argc, char *argv[] )
qgis->menuBar()->setVisible( true );
#endif

UnixSignalWatcher sigwatch;
sigwatch.watchForSignal( SIGINT );

QObject::connect( &sigwatch, &UnixSignalWatcher::unixSignal, &myApp, [&myApp ]( int signal )
{
switch ( signal )
{
case SIGINT:
myApp.exit( 1 );
break;

default:
break;
}
} );

int retval = myApp.exec();
delete qgis;
return retval;

0 comments on commit 534ff68

Please sign in to comment.
You can’t perform that action at this time.