Merge pull request #7292 from zzmp/fix/cache-loaded

Mark Resource loaded after postprocessing
This commit is contained in:
Chris Collins 2016-03-09 16:31:45 -08:00
commit 690d877e93
8 changed files with 15 additions and 15 deletions

View file

@ -132,6 +132,7 @@ void Animation::animationParseSuccess(FBXGeometry* geometry) {
void Animation::animationParseError(int error, QString str) {
qCCritical(animation) << "Animation failure parsing " << _url.toDisplayString() << "code =" << error << str;
emit failed(QNetworkReply::UnknownContentError);
finishedLoading(false);
}
AnimationDetails::AnimationDetails() :

View file

@ -80,6 +80,8 @@ void Sound::downloadFinished(const QByteArray& data) {
qCDebug(audio) << "Unknown sound file type";
}
finishedLoading(true);
_isReady = true;
emit ready();
}

View file

@ -15,6 +15,7 @@ NetworkShader::NetworkShader(const QUrl& url, bool delayLoad)
void NetworkShader::downloadFinished(const QByteArray& data) {
_source = QString::fromUtf8(data);
finishedLoading(true);
}
ShaderCache& ShaderCache::instance() {

View file

@ -344,9 +344,7 @@ void NetworkTexture::setImage(const QImage& image, void* voidTexture, int origin
_width = _height = 0;
}
_isCacheable = true;
finishedLoading(true);
emit networkTextureCreated(qWeakPointerCast<NetworkTexture, Resource> (_self));
}

View file

@ -132,7 +132,7 @@ signals:
protected:
virtual bool isCacheable() const override { return _isCacheable; }
virtual bool isCacheable() const override { return _loaded; }
virtual void downloadFinished(const QByteArray& data) override;
@ -148,7 +148,6 @@ private:
int _originalHeight { 0 };
int _width { 0 };
int _height { 0 };
bool _isCacheable { false };
};
#endif // hifi_TextureCache_h

View file

@ -371,7 +371,6 @@ void Resource::handleReplyFinished() {
auto extraInfo = _url == _activeUrl ? "" : QString(", %1").arg(_activeUrl.toDisplayString());
qCDebug(networking).noquote() << QString("Request finished for %1%2").arg(_url.toDisplayString(), extraInfo);
finishedLoading(true);
emit loaded(_data);
downloadFinished(_data);
} else {
@ -409,10 +408,6 @@ void Resource::handleReplyFinished() {
_request = nullptr;
}
void Resource::downloadFinished(const QByteArray& data) {
}
uint qHash(const QPointer<QObject>& value, uint seed) {
return qHash(value.data(), seed);
}

View file

@ -177,13 +177,14 @@ public:
const QByteArray& getData() const { return _data; }
signals:
/// Fired when the resource has been loaded.
/// Fired when the resource has been downloaded.
/// This can be used instead of downloadFinished to access data before it is processed.
void loaded(const QByteArray& request);
/// Fired when resource failed to load.
/// Fired when the resource failed to load.
void failed(QNetworkReply::NetworkError error);
/// Fired when resource is refreshed.
/// Fired when the resource is refreshed.
void onRefresh();
protected slots:
@ -195,10 +196,12 @@ protected:
/// Checks whether the resource is cacheable.
virtual bool isCacheable() const { return true; }
/// Called when the download has finished
virtual void downloadFinished(const QByteArray& data);
/// Called when the download has finished.
/// This should be overridden by subclasses that need to process the data once it is downloaded.
virtual void downloadFinished(const QByteArray& data) { finishedLoading(true); }
/// Should be called by subclasses when all the loading that will be done has been done.
/// Called when the download is finished and processed.
/// This should be called by subclasses that override downloadFinished to mark the end of processing.
Q_INVOKABLE void finishedLoading(bool success);
/// Reinserts this resource into the cache.

View file

@ -23,6 +23,7 @@ void NetworkClip::init(const QByteArray& clipData) {
void NetworkClipLoader::downloadFinished(const QByteArray& data) {
_clip->init(data);
finishedLoading(true);
}
ClipCache& ClipCache::instance() {