Provide instance()-method for Utils::NetworkAccessManager.

Preemptively fix exit warning "QEventLoop cannot be used
without QApplication" (Qt 5/dev) emitted by destruction of
the of the generic highlighter manager singleton which had a
member of type Utils::NetworkAccessManager.

Use a single instance of Utils::NetworkAccessManager for the
main thread and clean up properly using a qAddPostRoutine().

Change-Id: Ida57b9028a79eb4927818ce49088ea567f3bdfd6
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Friedemann Kleint
2013-04-09 09:58:17 +02:00
parent 2ead48fb26
commit 9d7e786b03
21 changed files with 54 additions and 103 deletions

View File

@@ -357,11 +357,6 @@ void GitoriousProjectReader::readUnknownElement(QXmlStreamReader &reader)
// --- Gitorious
Gitorious::Gitorious() :
m_networkManager(0)
{
}
Gitorious &Gitorious::instance()
{
static Gitorious gitorious;
@@ -523,9 +518,7 @@ void Gitorious::slotReplyFinished()
// dispatch. Use host name in case an entry is removed in-between
QNetworkReply *Gitorious::createRequest(const QUrl &url, int protocol, int hostIndex, int page)
{
if (!m_networkManager)
m_networkManager = new Utils::NetworkAccessManager(this);
QNetworkReply *reply = m_networkManager->get(QNetworkRequest(url));
QNetworkReply *reply = Utils::NetworkAccessManager::instance()->get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), this, SLOT(slotReplyFinished()));
reply->setProperty(protocolPropertyC, QVariant(protocol));
reply->setProperty(hostNamePropertyC, QVariant(hostName(hostIndex)));

View File

@@ -36,7 +36,6 @@
#include <QObject>
QT_BEGIN_NAMESPACE
class QNetworkAccessManager;
class QNetworkReply;
class QDebug;
class QUrl;
@@ -159,7 +158,7 @@ private slots:
void slotReplyFinished();
private:
Gitorious();
Gitorious() {}
void listProjectsReply(int hostIndex, int page, const QByteArray &data);
void listCategoriesReply(int index, QByteArray data);
void emitError(const QString &e);
@@ -167,7 +166,6 @@ private:
void startProjectsRequest(int index, int page = 1);
QList<GitoriousHost> m_hosts;
QNetworkAccessManager *m_networkManager;
};
} // namespace Internal