Fix download/question crashes

This commit is contained in:
Florian Bruhin 2014-06-26 13:33:18 +02:00
parent ca3df5e169
commit 46d621629f
2 changed files with 11 additions and 10 deletions

View File

@ -394,7 +394,7 @@ class DownloadManager(QObject):
self.questions.append(q) self.questions.append(q)
download.cancelled.connect(q.abort) download.cancelled.connect(q.abort)
download.cancelled.connect(q.deleteLater) download.cancelled.connect(q.deleteLater)
message.instance().question.emit(q, False) message.instance().ask(q, blocking=False)
@pyqtSlot(DownloadItem) @pyqtSlot(DownloadItem)
def on_finished(self, download): def on_finished(self, download):

View File

@ -68,7 +68,7 @@ def ask(message, mode, default=None):
q.text = message q.text = message
q.mode = mode q.mode = mode
q.default = default q.default = default
instance().question.emit(q, True) instance().ask(q, blocking=True)
q.deleteLater() q.deleteLater()
return q.answer return q.answer
@ -78,7 +78,7 @@ def alert(message):
q = Question() q = Question()
q.text = message q.text = message
q.mode = PromptMode.alert q.mode = PromptMode.alert
instance().question.emit(q, True) instance().ask(q, blocking=True)
q.deleteLater() q.deleteLater()
@ -97,7 +97,7 @@ def ask_async(message, mode, handler, default=None):
q.mode = mode q.mode = mode
q.default = default q.default = default
q.answered.connect(handler) q.answered.connect(handler)
bridge.queue(bridge.question, q, False) bridge.ask(q, blocking=False)
def confirm_async(message, yes_action, no_action=None, default=None): def confirm_async(message, yes_action, no_action=None, default=None):
@ -117,7 +117,7 @@ def confirm_async(message, yes_action, no_action=None, default=None):
q.answered_yes.connect(yes_action) q.answered_yes.connect(yes_action)
if no_action is not None: if no_action is not None:
q.answered_no.connect(no_action) q.answered_no.connect(no_action)
bridge.queue(bridge.question, q, False) bridge.ask(q, blocking=False)
class MessageBridge(QObject): class MessageBridge(QObject):
@ -171,10 +171,11 @@ class MessageBridge(QObject):
Args: Args:
msg: The message to show. msg: The message to show.
queue: Whether to queue the message (True) or display it immediately: Whether to display the message immediately (True) or
immediately (False). Messages resulting from direct user queue it for displaying when all other messages are
input should be displayed immediately, all other messages displayed (False). Messages resulting from direct user
should be queued. input should be displayed immediately, all other
messages should be queued.
""" """
msg = str(msg) msg = str(msg)
logger.error(msg) logger.error(msg)
@ -225,4 +226,4 @@ class MessageBridge(QObject):
blocking: Whether to return immediately or wait until the blocking: Whether to return immediately or wait until the
question is answered. question is answered.
""" """
self.question.emit(question, blocking) self.s_question.emit(question, blocking)