Switched BillboardOverlay to NetworkAccessManaqer

This commit is contained in:
Atlante45 2014-07-01 17:44:38 -07:00
parent c5a997a567
commit ab15a1487e
2 changed files with 6 additions and 13 deletions

View file

@ -14,8 +14,7 @@
#include "BillboardOverlay.h"
BillboardOverlay::BillboardOverlay()
: _manager(NULL),
_scale(1.0f),
: _scale(1.0f),
_isFacingAvatar(true) {
}
@ -119,18 +118,13 @@ void BillboardOverlay::setProperties(const QScriptValue &properties) {
}
}
// TODO: handle setting image multiple times, how do we manage releasing the bound texture?
void BillboardOverlay::setBillboardURL(const QUrl url) {
// TODO: are we creating too many QNetworkAccessManager() when multiple calls to setImageURL are made?
_manager->deleteLater();
_manager = new QNetworkAccessManager();
connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
_manager->get(QNetworkRequest(url));
QNetworkReply* reply = NetworkAccessManager::getInstance().get(QNetworkRequest(url));
connect(reply, &QNetworkReply::finished, this, &BillboardOverlay::replyFinished);
}
void BillboardOverlay::replyFinished(QNetworkReply* reply) {
void BillboardOverlay::replyFinished() {
// replace our byte array with the downloaded data
QNetworkReply* reply = static_cast<QNetworkReply*>(sender());
_billboard = reply->readAll();
_manager->deleteLater();
_manager = NULL;
}

View file

@ -27,12 +27,11 @@ public:
virtual void setProperties(const QScriptValue& properties);
private slots:
void replyFinished(QNetworkReply* reply);
void replyFinished();
private:
void setBillboardURL(const QUrl url);
QNetworkAccessManager* _manager;
QUrl _url;
QByteArray _billboard;
QSize _size;