MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / checkLatestRelease

Method checkLatestRelease

pj_runtime/src/UpdateChecker.cpp:37–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void UpdateChecker::checkLatestRelease() {
38 // Abandon any in-flight check. abort() makes that reply emit finished() with
39 // OperationCanceledError, which handleReply() drops silently; and because each
40 // handler captures its own `reply`, superseding a check can never make an old
41 // reply's handler act on the new request.
42 if (pending_reply_ && pending_reply_->isRunning()) {
43 pending_reply_->abort();
44 }
45
46 QNetworkRequest request(release_api_url_);
47 request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
48 // api.github.com rejects requests without a User-Agent (HTTP 403).
49 request.setHeader(QNetworkRequest::UserAgentHeader, QStringLiteral("PlotJuggler"));
50 request.setRawHeader("Accept", "application/vnd.github+json");
51 request.setTransferTimeout(kTransferTimeoutMs);
52
53 QNetworkReply* reply = network_->get(request);
54 pending_reply_ = reply;
55 connect(reply, &QNetworkReply::finished, this, [this, reply]() {
56 if (pending_reply_ == reply) {
57 pending_reply_ = nullptr;
58 }
59 handleReply(reply);
60 });
61}
62
63void UpdateChecker::handleReply(QNetworkReply* reply) {
64 if (!reply) {

Callers 2

TESTFunction · 0.80
checkForUpdatesMethod · 0.80

Calls 2

getMethod · 0.80
setAttributeMethod · 0.45

Tested by 1

TESTFunction · 0.64