mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Defensive programming
Long API calls might return after the Local or Remote PackageList has been deconstructed. Somehow setting the ownership in QML doesn't seem to work for this. So we guard against this with a try catch block. Contributes to: CURA-8587
This commit is contained in:
parent
6c976bc9b0
commit
453de95d12
2 changed files with 17 additions and 6 deletions
|
@ -218,6 +218,11 @@ class PackageList(ListModel):
|
|||
Logger.error(f"Failed to write downloaded package to temp file {e}")
|
||||
temp_file.close()
|
||||
self._downloadError(package_id, update)
|
||||
except RuntimeError:
|
||||
# Setting the ownership of this object to not qml can still result in a RuntimeError. Which can occur when quickly toggling
|
||||
# between de-/constructing Remote or Local PackageLists. This try-except is here to prevent a hard crash when the wrapped C++ object
|
||||
# was deleted when it was still parsing the response
|
||||
return
|
||||
|
||||
def _downloadError(self, package_id: str, update: bool = False, reply: Optional["QNetworkReply"] = None, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||
if reply:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue