CURA-5035 No more crash without internet connection

Still needs a timer or something to show the fetch failed though.
This commit is contained in:
Ian Paschal 2018-05-02 14:30:31 +02:00
parent f7ca8cbf68
commit 4e62c58ee6
3 changed files with 32 additions and 2 deletions

View file

@ -314,8 +314,9 @@ class Toolbox(QObject, Extension):
return
def resetDownload(self):
self._download_reply.abort()
self._download_reply.downloadProgress.disconnect(self._onDownloadProgress)
if self._download_reply:
self._download_reply.abort()
self._download_reply.downloadProgress.disconnect(self._onDownloadProgress)
self._download_reply = None
self._download_request = None
self.setDownloadProgress(0)
@ -333,11 +334,13 @@ class Toolbox(QObject, Extension):
if reply.error() == QNetworkReply.TimeoutError:
Logger.log("w", "Got a timeout.")
self.setViewPage("errored")
self.resetDownload()
return
if reply.error() == QNetworkReply.HostNotFoundError:
Logger.log("w", "Unable to reach server.")
self.setViewPage("errored")
self.resetDownload()
return