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

Method handleReply

pj_runtime/src/UpdateChecker.cpp:63–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void UpdateChecker::handleReply(QNetworkReply* reply) {
64 if (!reply) {
65 emit checkFailed(QStringLiteral("no reply"));
66 return;
67 }
68
69 // A self-inflicted abort (a newer check superseded this one) is not a
70 // user-facing failure — drop it without emitting any outcome.
71 if (reply->error() == QNetworkReply::OperationCanceledError) {
72 reply->deleteLater();
73 return;
74 }
75
76 // A 404 (no release published yet) surfaces here as ContentNotFoundError —
77 // treated like any other failure, i.e. silently on the startup path.
78 if (reply->error() != QNetworkReply::NoError) {
79 emit checkFailed(reply->errorString());
80 reply->deleteLater();
81 return;
82 }
83
84 const QByteArray data = reply->readAll();
85 reply->deleteLater();
86
87 QJsonParseError parse_error;
88 const QJsonDocument doc = QJsonDocument::fromJson(data, &parse_error);
89 if (parse_error.error != QJsonParseError::NoError) {
90 emit checkFailed(QStringLiteral("release JSON parse error: %1").arg(parse_error.errorString()));
91 return;
92 }
93 if (!doc.isObject()) {
94 emit checkFailed(QStringLiteral("release response was not a JSON object"));
95 return;
96 }
97
98 const QJsonObject obj = doc.object();
99 const QString tag_name = obj.value(QStringLiteral("tag_name")).toString();
100 if (tag_name.isEmpty()) {
101 emit checkFailed(QStringLiteral("release JSON missing tag_name"));
102 return;
103 }
104
105 const QString current = current_version_.isEmpty() ? QCoreApplication::applicationVersion() : current_version_;
106
107 if (!isNewerVersion(tag_name, current)) {
108 emit upToDate();
109 return;
110 }
111
112 const QString name = obj.value(QStringLiteral("name")).toString();
113 const QString html_url = obj.value(QStringLiteral("html_url")).toString();
114 emit updateAvailable(ReleaseInfo{name.isEmpty() ? tag_name : name, html_url});
115}
116
117} // namespace PJ

Callers

nothing calls this directly

Calls 4

isNewerVersionFunction · 0.85
toStringMethod · 0.80
valueMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected