2013-08-07 00:38:18 +01:00
|
|
|
#include "NetWorker.h"
|
|
|
|
#include <QThreadStorage>
|
|
|
|
|
2013-09-01 23:25:40 +01:00
|
|
|
class NetWorker::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QNetworkAccessManager manager;
|
|
|
|
};
|
|
|
|
|
|
|
|
NetWorker::NetWorker ( QObject* parent ) : QObject ( parent )
|
|
|
|
{
|
|
|
|
d = new Private();
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkAccessManager& NetWorker::qnam()
|
|
|
|
{
|
|
|
|
auto & w = worker();
|
|
|
|
return w.d->manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NetWorker& NetWorker::worker()
|
2013-08-07 00:38:18 +01:00
|
|
|
{
|
|
|
|
static QThreadStorage<NetWorker *> storage;
|
|
|
|
if (!storage.hasLocalData())
|
|
|
|
{
|
|
|
|
storage.setLocalData(new NetWorker());
|
|
|
|
}
|
|
|
|
return *storage.localData();
|
|
|
|
}
|