From a0467cd66f665d8c0adb684d40c81b9464b02486 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Thu, 4 Nov 2021 10:39:00 +0100 Subject: [PATCH] Fixed hard crash when deconstructing RemotePackageList while parsing Contributes to CURA-8558 --- plugins/Marketplace/RemotePackageList.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/Marketplace/RemotePackageList.py b/plugins/Marketplace/RemotePackageList.py index 3a6a329a52..8fa75453c1 100644 --- a/plugins/Marketplace/RemotePackageList.py +++ b/plugins/Marketplace/RemotePackageList.py @@ -107,8 +107,14 @@ class RemotePackageList(PackageList): return for package_data in response_data["data"]: - package = PackageModel(package_data, parent = self) - self.appendItem({"package": package}) # Add it to this list model. + 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