From 6d3a9952cf713dc9bf70710ed04f5db7d7c98869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Tue, 15 Apr 2014 15:59:43 -0300 Subject: Properly stop the Qt app before stopping the reactor --- src/leap/bitmask/gui/twisted_main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/leap') 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') -- cgit v1.2.3