summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorantialias <antialias@leap.se>2012-11-21 15:34:32 -0800
committerkali <kali@leap.se>2012-11-28 02:10:13 +0900
commitc7dec38062e433cd1f098b6f1457acc87b4e6aaf (patch)
tree267b0d41697a3d9efde5d737023925b7a37fdf77 /src/leap
parenteec567a0a26edddb30b15ea4ef67f042c160d5ba (diff)
successfully catching ctrl-c but for not quitting in the correct order.
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/app.py19
-rw-r--r--src/leap/baseapp/mainwindow.py1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index 4dd93600..c88ca913 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -1,15 +1,23 @@
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
+from functools import partial
import logging
+import signal
# This is only needed for Python v2 but is harmless for Python v3.
import sip
sip.setapi('QVariant', 2)
sip.setapi('QString', 2)
from PyQt4.QtGui import (QApplication, QSystemTrayIcon, QMessageBox)
+from PyQt4.QtCore import QTimer
+from PyQt4 import QtCore
from leap import __version__ as VERSION
from leap.baseapp.mainwindow import LeapWindow
+def sigint_handler(*args):
+ #import pdb4qt as pdb; pdb.set_trace()
+ app = args[0]
+ app.cleanupAndQuit()
def main():
"""
@@ -52,6 +60,10 @@ def main():
logger.info('Starting app')
app = QApplication(sys.argv)
+ timer = QTimer()
+ timer.start(500)
+ timer.timeout.connect(lambda: None)
+
# needed for initializing qsettings
# it will write .config/leap/leap.conf
# top level app settings
@@ -69,6 +81,13 @@ def main():
QApplication.setQuitOnLastWindowClosed(False)
window = LeapWindow(opts)
+
+ sigint_window = partial(sigint_handler, window)
+ signal.signal(signal.SIGINT, sigint_window)
+ #signal.signal(signal.SIGINT, lambda: QtCore.QMetaObject.invokeMethod(window, 'cleanupAndQuit'))
+ #window.shutdownSignal.connect(window.cleanupAndQuit)
+ #signal.signal(signal.SIGINT, window.shutdownSignal.emit))
+
if debug:
# we only show the main window
# if debug mode active.
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index f07ebb7d..85185ca6 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -40,6 +40,7 @@ class LeapWindow(QtGui.QMainWindow,
networkError = QtCore.pyqtSignal([object])
triggerEIPError = QtCore.pyqtSignal([object])
start_eipconnection = QtCore.pyqtSignal([])
+ shutdownSignal = QtCore.pyqtSignal([])
# this is status change got from openvpn management
openvpnStatusChange = QtCore.pyqtSignal([object])