Mercurial > hg > svapp
diff framework/VersionTester.cpp @ 287:8cb01cd2441d sv_v2.1
Delete things
author | Chris Cannam |
---|---|
date | Thu, 16 May 2013 14:05:02 +0100 |
parents | 3c236d31cccd |
children | 068235cf5bf7 |
line wrap: on
line diff
--- a/framework/VersionTester.cpp Tue May 14 16:02:52 2013 +0100 +++ b/framework/VersionTester.cpp Thu May 16 14:05:02 2013 +0100 @@ -25,17 +25,17 @@ #include <QNetworkAccessManager> -static QNetworkAccessManager nm; VersionTester::VersionTester(QString hostname, QString versionFilePath, QString myVersion) : m_myVersion(myVersion), m_reply(0), - m_httpFailed(false) + m_httpFailed(false), + m_nm(new QNetworkAccessManager) { QUrl url(QString("http://%1/%2").arg(hostname).arg(versionFilePath)); std::cerr << "VersionTester: URL is " << url << std::endl; - m_reply = nm.get(QNetworkRequest(url)); + m_reply = m_nm->get(QNetworkRequest(url)); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); connect(m_reply, SIGNAL(finished()), this, SLOT(finished())); @@ -47,6 +47,7 @@ m_reply->abort(); m_reply->deleteLater(); } + delete m_nm; } bool @@ -84,16 +85,19 @@ void VersionTester::finished() { - m_reply->deleteLater(); + QNetworkReply *r = m_reply; + m_reply = 0; + + r->deleteLater(); if (m_httpFailed) return; - int status = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + int status = r->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (status / 100 != 2) { std::cerr << "VersionTester: error: http status = " << status << std::endl; return; } - QByteArray responseData = m_reply->readAll(); + QByteArray responseData = r->readAll(); QString str = QString::fromUtf8(responseData.data()); QStringList lines = str.split('\n', QString::SkipEmptyParts); if (lines.empty()) return;