Disconnect upload finished signals, move already uploading check down, CURA-4398

This commit is contained in:
ChrisTerBeke 2017-10-05 13:11:45 +02:00
parent a8476c30ca
commit cd59048475

View File

@ -485,6 +485,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
Logger.log("d", "Stopping post upload because the connection was lost.") Logger.log("d", "Stopping post upload because the connection was lost.")
try: try:
self._post_reply.uploadProgress.disconnect(self._onUploadProgress) self._post_reply.uploadProgress.disconnect(self._onUploadProgress)
self._post_reply.finished.disconnect(self._onUploadFinished)
except TypeError: except TypeError:
pass # The disconnection can fail on mac in some cases. Ignore that. pass # The disconnection can fail on mac in some cases. Ignore that.
@ -517,6 +518,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
Logger.log("d", "Stopping post upload because the connection was lost.") Logger.log("d", "Stopping post upload because the connection was lost.")
try: try:
self._post_reply.uploadProgress.disconnect(self._onUploadProgress) self._post_reply.uploadProgress.disconnect(self._onUploadProgress)
self._post_reply.finished.disconnect(self._onUploadFinished)
except TypeError: except TypeError:
pass # The disconnection can fail on mac in some cases. Ignore that. pass # The disconnection can fail on mac in some cases. Ignore that.
@ -652,14 +654,6 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
# \param kwargs Keyword arguments. # \param kwargs Keyword arguments.
def requestWrite(self, nodes, file_name=None, filter_by_machine=False, file_handler=None, **kwargs): def requestWrite(self, nodes, file_name=None, filter_by_machine=False, file_handler=None, **kwargs):
# Check if we're already writing
if not self._write_finished:
self._error_message = Message(
i18n_catalog.i18nc("@info:status",
"Sending new jobs (temporarily) blocked, still sending the previous print job."))
self._error_message.show()
return
if self._printer_state not in ["idle", ""]: if self._printer_state not in ["idle", ""]:
self._error_message = Message( self._error_message = Message(
i18n_catalog.i18nc("@info:status", "Unable to start a new print job, printer is busy. Current printer status is %s.") % self._printer_state, i18n_catalog.i18nc("@info:status", "Unable to start a new print job, printer is busy. Current printer status is %s.") % self._printer_state,
@ -759,6 +753,14 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
) )
return return
# Check if we're already writing
if not self._write_finished:
self._error_message = Message(
i18n_catalog.i18nc("@info:status",
"Sending new jobs (temporarily) blocked, still sending the previous print job."))
self._error_message.show()
return
# Indicate we're starting a new write action, is set back to True in the startPrint() method # Indicate we're starting a new write action, is set back to True in the startPrint() method
self._write_finished = False self._write_finished = False
@ -996,6 +998,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
if self._post_reply: if self._post_reply:
self._post_reply.abort() self._post_reply.abort()
self._post_reply.uploadProgress.disconnect(self._onUploadProgress) self._post_reply.uploadProgress.disconnect(self._onUploadProgress)
self._post_reply.finished.disconnect(self._onUploadFinished)
Logger.log("d", "Uploading of print failed after %s", time() - self._send_gcode_start) Logger.log("d", "Uploading of print failed after %s", time() - self._send_gcode_start)
self._post_reply = None self._post_reply = None
self._progress_message.hide() self._progress_message.hide()
@ -1177,6 +1180,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
del self._material_post_objects[id(reply)] del self._material_post_objects[id(reply)]
elif "print_job" in reply_url: elif "print_job" in reply_url:
reply.uploadProgress.disconnect(self._onUploadProgress) reply.uploadProgress.disconnect(self._onUploadProgress)
reply.finished.disconnect(self._onUploadFinished)
Logger.log("d", "Uploading of print succeeded after %s", time() - self._send_gcode_start) Logger.log("d", "Uploading of print succeeded after %s", time() - self._send_gcode_start)
# Only reset the _post_reply if it was the same one. # Only reset the _post_reply if it was the same one.
if reply == self._post_reply: if reply == self._post_reply: