Launcher: fix crash on slow update check
Cancel the update check HTTP request when the launcher ends, so we don’t crash if the response arrives. Sentry-Id: FLIGHTGEAR-DYT
This commit is contained in:
parent
64b03b70a8
commit
89de1defa0
2 changed files with 16 additions and 4 deletions
|
@ -55,8 +55,6 @@ private:
|
|||
|
||||
void onDone() override
|
||||
{
|
||||
|
||||
|
||||
int response = responseCode();
|
||||
if (response == 200) {
|
||||
// send response to the main thread for processing
|
||||
|
@ -105,13 +103,22 @@ UpdateChecker::UpdateChecker(QObject *parent) : QObject(parent)
|
|||
|
||||
// definitiely want to ensure HTTPS for this.
|
||||
std::string uri = "https://download.flightgear.org/builds/" + _majorMinorVersion + "/updates.xml";
|
||||
auto req = new UpdateXMLRequest(this, uri);
|
||||
http->makeRequest(req);
|
||||
m_request = new UpdateXMLRequest(this, uri);
|
||||
http->makeRequest(m_request);
|
||||
} else {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
UpdateChecker::~UpdateChecker()
|
||||
{
|
||||
if (m_request) {
|
||||
auto http = globals->get_subsystem<FGHTTPClient>();
|
||||
http->client()->cancelRequest(m_request);
|
||||
m_request.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateChecker::ignoreUpdate()
|
||||
{
|
||||
QSettings settings;
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <QByteArray>
|
||||
#include <QUrl>
|
||||
|
||||
#include <simgear/io/HTTPRequest.hxx>
|
||||
|
||||
class UpdateChecker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -33,6 +35,7 @@ class UpdateChecker : public QObject
|
|||
Q_PROPERTY(QString updateVersion READ updateVersion NOTIFY statusChanged)
|
||||
public:
|
||||
explicit UpdateChecker(QObject *parent = nullptr);
|
||||
~UpdateChecker();
|
||||
|
||||
enum Status {
|
||||
NoUpdate,
|
||||
|
@ -75,5 +78,7 @@ private:
|
|||
|
||||
Status m_status = NoUpdate;
|
||||
QUrl m_updateUri;
|
||||
|
||||
simgear::HTTP::Request_ptr m_request;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue