Mercurial > hg > svapp
changeset 287:8cb01cd2441d sv_v2.1
Delete things
author | Chris Cannam |
---|---|
date | Thu, 16 May 2013 14:05:02 +0100 |
parents | 489bb1ba1202 |
children | 868db2bf6a69 |
files | framework/VersionTester.cpp framework/VersionTester.h |
diffstat | 2 files changed, 13 insertions(+), 6 deletions(-) [+] |
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;
--- a/framework/VersionTester.h Tue May 14 16:02:52 2013 +0100 +++ b/framework/VersionTester.h Thu May 16 14:05:02 2013 +0100 @@ -26,6 +26,8 @@ #include <QObject> #include <QNetworkReply> +class QNetworkAccessManager; + class VersionTester : public QObject { Q_OBJECT @@ -47,6 +49,7 @@ QString m_myVersion; QNetworkReply *m_reply; bool m_httpFailed; + QNetworkAccessManager *m_nm; }; #endif