diff options
author | antialias <antialias@leap.se> | 2012-11-21 15:34:32 -0800 |
---|---|---|
committer | kali <kali@leap.se> | 2012-11-28 02:10:13 +0900 |
commit | c7dec38062e433cd1f098b6f1457acc87b4e6aaf (patch) | |
tree | 267b0d41697a3d9efde5d737023925b7a37fdf77 /src/leap/app.py | |
parent | eec567a0a26edddb30b15ea4ef67f042c160d5ba (diff) |
successfully catching ctrl-c but for not quitting in the correct order.
Diffstat (limited to 'src/leap/app.py')
-rw-r--r-- | src/leap/app.py | 19 |
1 files changed, 19 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. |