summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-04-15 15:59:43 -0300
committerTomás Touceda <chiiph@leap.se>2014-04-16 11:45:52 -0300
commit6d3a9952cf713dc9bf70710ed04f5db7d7c98869 (patch)
tree54e0a108c47386c994e7a3bbd9b55379650d18c8 /src/leap
parent64e25fc8cf8a2f8c1fec6388e1f76312831b5f2a (diff)
Properly stop the Qt app before stopping the reactor
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/gui/twisted_main.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/leap/bitmask/gui/twisted_main.py b/src/leap/bitmask/gui/twisted_main.py
index 1e876c57..ece32ca2 100644
--- a/src/leap/bitmask/gui/twisted_main.py
+++ b/src/leap/bitmask/gui/twisted_main.py
@@ -19,7 +19,8 @@ Main functions for integration of twisted reactor
"""
import logging
-from twisted.internet import error
+from twisted.internet import error, reactor
+from PySide import QtCore
# Resist the temptation of putting the import reactor here,
# it will raise an "reactor already imported" error.
@@ -27,6 +28,14 @@ from twisted.internet import error
logger = logging.getLogger(__name__)
+def stop():
+ logger.debug("Really stoping all the things...")
+ QtCore.QCoreApplication.sendPostedEvents()
+ QtCore.QCoreApplication.flush()
+ reactor.stop()
+ logger.debug("Done stopping all the things.")
+
+
def quit(app):
"""
Stop the mainloop.
@@ -34,9 +43,8 @@ def quit(app):
:param app: the main qt QApplication instance.
:type app: QtCore.QApplication
"""
- from twisted.internet import reactor
logger.debug('Stopping twisted reactor')
try:
- reactor.callLater(0, reactor.stop)
+ reactor.callLater(0, stop)
except error.ReactorNotRunning:
logger.debug('Reactor not running')