diff --git a/plugins/Marketplace/LocalPackageList.py b/plugins/Marketplace/LocalPackageList.py index c3491fc3af..6fb9cfbf34 100644 --- a/plugins/Marketplace/LocalPackageList.py +++ b/plugins/Marketplace/LocalPackageList.py @@ -95,10 +95,16 @@ class LocalPackageList(PackageList): if len(response_data["data"]) == 0: return - for package_data in response_data["data"]: - package = self.getPackageModel(package_data["package_id"]) - package.download_url = package_data.get("download_url", "") - package.can_update = True + try: + for package_data in response_data["data"]: + package = self.getPackageModel(package_data["package_id"]) + package.download_url = package_data.get("download_url", "") + package.can_update = True - self.sort(attrgetter("sectionTitle", "can_update", "displayName"), key = "package", reverse = True) - self._ongoing_requests["check_updates"] = None + self.sort(attrgetter("sectionTitle", "can_update", "displayName"), key = "package", reverse = True) + self._ongoing_requests["check_updates"] = None + 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 diff --git a/plugins/Marketplace/PackageList.py b/plugins/Marketplace/PackageList.py index a2c67dc1ef..7e64373e9c 100644 --- a/plugins/Marketplace/PackageList.py +++ b/plugins/Marketplace/PackageList.py @@ -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: