# HG changeset patch # User Chris Cannam # Date 1368709502 -3600 # Node ID 8cb01cd2441d1009fce5c1234ecbe033ce45484a # Parent 489bb1ba12025ace5dc0da53072d24019d158f8d Delete things diff -r 489bb1ba1202 -r 8cb01cd2441d framework/VersionTester.cpp --- 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 -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; diff -r 489bb1ba1202 -r 8cb01cd2441d framework/VersionTester.h --- 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 #include +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