Skip to content

Commit

Permalink
version_checker: don't delete network reply in finished handler
Browse files Browse the repository at this point in the history
The Qt docs warn against deleting a QNetworkReply while the
`finished` handler is running (https://doc.qt.io/qt-6/qnetworkreply.html).

We're not explicitly deleting it here, just setting the Python reference
to `None`, but that might be enough to cause the object to be
destroyed, explaining the crash we're seeing on Windows.

Instead we set the option on QNetworkAccessManager to auto-delete
replies.
  • Loading branch information
jonathanperret committed Oct 31, 2024
1 parent 92fa698 commit fe324f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/python/main/ayab/version_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def start_background_check(self) -> None:
latest_relase_url = f"https://api.github.com/repos/{self.REPO}/releases/latest"
self.logger.debug("Getting %s", latest_relase_url)
self._network_manager = QNetworkAccessManager()
self._network_manager.setAutoDeleteReplies(True)
self._version_check_reply = self._network_manager.get(
QNetworkRequest(latest_relase_url)
)
Expand Down Expand Up @@ -96,5 +97,4 @@ def version_check_finished(self) -> None:
finally:
# make sure to free resources once done
self.logger.debug("Cleaning up")
self._version_check_reply = None
self._network_manager = None

0 comments on commit fe324f3

Please sign in to comment.