History

Pull Request fixes

Leonardo Murillo committed 12 years ago

Commit cd9f2fd1 parent 865045a4 files · +36 −43Browse files

Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Application.cpp+20−31
@@ -95,6 +95,7 @@ const float MIRROR_REARVIEW_DISTANCE = 0.65f; · 94 unmodified lines
9595 const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f;
9696
9797 const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
98+const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
9899
99100 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
100101 QString messageWithNewLine = message + "\n";
@@ -202,8 +203,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 101 unmodified lines
202203 setOrganizationName(applicationInfo.value("organizationName").toString());
203204 setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
204205
205− checkVersion();
206−
207206 qDebug("[VERSION] Build sequence: %s\n", applicationVersion().toStdString().c_str());
208207
209208 _settings = new QSettings(this);
@@ -262,7 +261,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 52 unmodified lines
262261
263262 // Set the sixense filtering
264263 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
265−
264+
265+ checkVersion();
266266 }
267267
268268 Application::~Application() {
@@ -4367,31 +4367,28 @@ void Application::updateLocalOctreeCache(bool firstTime) { · 4098 unmodified lines
43674367
43684368 void Application::checkVersion() {
43694369 QUrl url(CHECK_VERSION_URL);
4370− QNetworkAccessManager *downloadXML = new QNetworkAccessManager(this);
4371− QNetworkRequest request(url);
4372− connect(downloadXML, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseVersionXml(QNetworkReply*)));
4373− downloadXML->get(request);
4370+ QNetworkRequest latestVersionRequest(url);
4371+ latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
4372+ _latestVersionReply = getNetworkAccessManager()->get(latestVersionRequest);
4373+
4374+ connect(_latestVersionReply, SIGNAL(readyRead()), SLOT(parseVersionXml()));
43744375 }
43754376
4376−void Application::parseVersionXml(QNetworkReply *reply) {
4377− QString *operatingSystem;
4377+void Application::parseVersionXml() {
43784378
43794379 #ifdef Q_OS_WIN32
4380− operatingSystem = new QString("win");
4380+ QString operatingSystem("win");
43814381 #endif
43824382
43834383 #ifdef Q_OS_MAC
4384− operatingSystem = new QString("mac");
4384+ QString operatingSystem("mac");
43854385 #endif
43864386
43874387 QString releaseDate;
43884388 QString releaseNotes;
43894389 QString latestVersion;
4390− QUrl downloadURL;
4391−
4392− QWidget *updateDialog;
43934390
4394− QXmlStreamReader xml(reply);
4391+ QXmlStreamReader xml(_latestVersionReply);
43954392 while (!xml.atEnd() && !xml.hasError()) {
43964393 QXmlStreamReader::TokenType token = xml.readNext();
43974394
@@ -4410,36 +4407,28 @@ void Application::parseVersionXml(QNetworkReply *reply) { · 12 unmodified lines
44104407 }
44114408 if (xml.name() == operatingSystem) {
44124409 xml.readNext();
4413− downloadURL = QUrl(xml.text().toString());
4410+ _downloadUrl = QUrl(xml.text().toString());
44144411 }
44154412 }
44164413 }
44174414
44184415 if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
4419− updateDialog = new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadURL);
4416+ new UpdateDialog(_glWidget, releaseNotes, latestVersion, _downloadUrl);
44204417 }
4418+
4419+ delete _latestVersionReply;
44214420 }
44224421
44234422 bool Application::shouldSkipVersion(QString latestVersion) {
4424− QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
4425− fileName.append(QString("/hifi.skipversion"));
4426− QFile skipFile(fileName);
4423+ QFile skipFile(SKIP_FILENAME);
44274424 skipFile.open(QIODevice::ReadWrite);
4428− QByteArray skipFileContents = skipFile.readAll();
4429− QString skipVersion(skipFileContents);
4430− skipFile.close();
4431− if (skipVersion == latestVersion || applicationVersion() == "dev") {
4432− return true;
4433− }
4434− return false;
4425+ QString skipVersion(skipFile.readAll());
4426+ return (skipVersion == latestVersion /*|| applicationVersion() == "dev"*/);
44354427 }
44364428
44374429 void Application::skipVersion(QString latestVersion) {
4438− QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
4439− fileName.append(QString("/hifi.skipversion"));
4440− QFile skipFile(fileName);
4430+ QFile skipFile(SKIP_FILENAME);
44414431 skipFile.open(QIODevice::WriteOnly|QIODevice::Truncate);
44424432 skipFile.seek(0);
44434433 skipFile.write(latestVersion.toStdString().c_str());
4444− skipFile.close();
44454434 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t