Fixed hard crash when deconstructing RemotePackageList while parsing

Contributes to CURA-8558
This commit is contained in:
Jelle Spijker 2021-11-04 10:39:00 +01:00 committed by Jelle Spijker
parent fd409215c4
commit a0467cd66f
No known key found for this signature in database
GPG key ID: 6662DC033BE6B99A

View file

@ -107,8 +107,14 @@ class RemotePackageList(PackageList):
return
for package_data in response_data["data"]:
try:
package = PackageModel(package_data, parent = self)
self.appendItem({"package": package}) # Add it to this list model.
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 RemotePackageLists. 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
self._request_url = response_data["links"].get("next", "") # Use empty string to signify that there is no next page.
self._ongoing_request = None