summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug_properly_finish_qtapp1
-rw-r--r--src/leap/bitmask/gui/twisted_main.py14
2 files changed, 12 insertions, 3 deletions
diff --git a/changes/bug_properly_finish_qtapp b/changes/bug_properly_finish_qtapp
new file mode 100644
index 00000000..cfe0f1d6
--- /dev/null
+++ b/changes/bug_properly_finish_qtapp
@@ -0,0 +1 @@
+- Properly finish the Qt app before stopping the reactor. \ No newline at end of file
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')