summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2014-04-10 13:05:55 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2014-04-10 13:05:55 -0300
commitfbb35a54cb645fe377a8518880c9f49e6f7b5d58 (patch)
treeefcefb3b9920ee872faca2213aa83a340555a183
parentc3a21a28ba3b3a8200959ec67b0447c982448941 (diff)
Use non blocking dialog for Pastebin result
With this change we no longer need to call the dialog with reactor.callLater. Also removed useless failure.trap Closes #5404.
-rw-r--r--changes/bug-5404_pastebin-dialog-blocks-app1
-rw-r--r--src/leap/bitmask/gui/loggerwindow.py30
2 files changed, 20 insertions, 11 deletions
diff --git a/changes/bug-5404_pastebin-dialog-blocks-app b/changes/bug-5404_pastebin-dialog-blocks-app
new file mode 100644
index 00000000..384a6f63
--- /dev/null
+++ b/changes/bug-5404_pastebin-dialog-blocks-app
@@ -0,0 +1 @@
+- Use non blocking dialog so the Pastebin result does not block the app. Closes #5404.
diff --git a/src/leap/bitmask/gui/loggerwindow.py b/src/leap/bitmask/gui/loggerwindow.py
index 9f396574..4bf20e35 100644
--- a/src/leap/bitmask/gui/loggerwindow.py
+++ b/src/leap/bitmask/gui/loggerwindow.py
@@ -21,14 +21,14 @@ History log window
import logging
import cgi
-from PySide import QtGui
+from PySide import QtCore, QtGui
from twisted.internet import threads
from ui_loggerwindow import Ui_LoggerWindow
from leap.bitmask.util.constants import PASTEBIN_API_DEV_KEY
from leap.bitmask.util.leap_log_handler import LeapLogHandler
-from leap.bitmask.util.pastebin import PastebinAPI, PastebinError
+from leap.bitmask.util.pastebin import PastebinAPI
from leap.common.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
@@ -220,12 +220,16 @@ class LoggerWindow(QtGui.QDialog):
:param link: the recently created pastebin link.
:type link: str
"""
+ self._set_pastebin_sending(False)
msg = self.tr("Your pastebin link <a href='{0}'>{0}</a>")
msg = msg.format(link)
- show_info = lambda: QtGui.QMessageBox.information(
- self, self.tr("Pastebin OK"), msg)
- self._set_pastebin_sending(False)
- self.reactor.callLater(0, show_info)
+
+ # We save the dialog in an instance member to avoid dialog being
+ # deleted right after we exit this method
+ self._msgBox = msgBox = QtGui.QMessageBox(
+ QtGui.QMessageBox.Information, self.tr("Pastebin OK"), msg)
+ msgBox.setWindowModality(QtCore.Qt.NonModal)
+ msgBox.show()
def pastebin_err(failure):
"""
@@ -234,13 +238,17 @@ class LoggerWindow(QtGui.QDialog):
:param failure: the failure that triggered the errback.
:type failure: twisted.python.failure.Failure
"""
+ self._set_pastebin_sending(False)
logger.error(repr(failure))
+
msg = self.tr("Sending logs to Pastebin failed!")
- show_err = lambda: QtGui.QMessageBox.critical(
- self, self.tr("Pastebin Error"), msg)
- self._set_pastebin_sending(False)
- self.reactor.callLater(0, show_err)
- failure.trap(PastebinError)
+
+ # We save the dialog in an instance member to avoid dialog being
+ # deleted right after we exit this method
+ self._msgBox = msgBox = QtGui.QMessageBox(
+ QtGui.QMessageBox.Critical, self.tr("Pastebin Error"), msg)
+ msgBox.setWindowModality(QtCore.Qt.NonModal)
+ msgBox.show()
self._set_pastebin_sending(True)
d = threads.deferToThread(do_pastebin)