summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2018-10-23 10:59:41 +0200
committerAleks Kissinger <aleks0@gmail.com>2018-10-23 10:59:41 +0200
commit0eb35874c48b3078782af671a21ede98f4f92093 (patch)
tree4edbe1134a72aa5dd5a590cbfaadb204c6c86f36
parent73dcc4c2dd5ee095ef8454f9c1d16787ee13d101 (diff)
back to http, but with input validation
-rw-r--r--src/tikzit.cpp16
-rw-r--r--src/tikzit.h2
2 files changed, 10 insertions, 8 deletions
diff --git a/src/tikzit.cpp b/src/tikzit.cpp
index 02b8578..820b8ec 100644
--- a/src/tikzit.cpp
+++ b/src/tikzit.cpp
@@ -363,7 +363,7 @@ void Tikzit::checkForUpdates()
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(updateReply(QNetworkReply*)));
- manager->get(QNetworkRequest(QUrl("https://tikzit.github.io/latest-version.txt")));
+ manager->get(QNetworkRequest(QUrl("http://tikzit.github.io/latest-version.txt")));
}
void Tikzit::updateReply(QNetworkReply *reply)
@@ -373,9 +373,6 @@ void Tikzit::updateReply(QNetworkReply *reply)
QByteArray data = reply->read(200);
QString strLatest = QString::fromUtf8(data).simplified();
- QVersionNumber current = QVersionNumber::fromString(TIKZIT_VERSION).normalized();
- QVersionNumber latest = QVersionNumber::fromString(strLatest).normalized();
-
// check for valid version string and capture optional RC suffix
QRegularExpression re("^[1-9]+(\\.[0-9]+)*(-[rR][cC]([0-9]+))?$");
QRegularExpressionMatch m;
@@ -387,12 +384,17 @@ void Tikzit::updateReply(QNetworkReply *reply)
m = re.match(strLatest);
if (m.hasMatch()) {
- int rcLatest = (!m.captured(3).isEmpty()) ? m.captured(3).toInt() : 1000;
+ QVersionNumber current = QVersionNumber::fromString(TIKZIT_VERSION).normalized();
+ QVersionNumber latest = QVersionNumber::fromString(strLatest).normalized();
- //qDebug() << "latest" << latest << "rc" << rcLatest;
- //qDebug() << "current" << current << "rc" << rcCurrent;
+ int rcLatest = (!m.captured(3).isEmpty()) ? m.captured(3).toInt() : 1000;
if (latest > current || (latest == current && rcLatest > rcCurrent)) {
+ // give the version string in standard format
+ strLatest = QString::number(latest.majorVersion()) + "." +
+ QString::number(latest.minorVersion()) + "." +
+ QString::number(latest.microVersion());
+ if (rcLatest != 1000) strLatest += "-rc" + QString::number(rcLatest);
QMessageBox::information(0,
tr("Update available"),
"<p><b>A new version of TikZiT is available!</b></p>"
diff --git a/src/tikzit.h b/src/tikzit.h
index 69e9237..d36a940 100644
--- a/src/tikzit.h
+++ b/src/tikzit.h
@@ -49,7 +49,7 @@
#ifndef TIKZIT_H
#define TIKZIT_H
-#define TIKZIT_VERSION "2.0"
+#define TIKZIT_VERSION "2.0.0"
#include "mainwindow.h"
#include "mainmenu.h"