mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 05:17:08 +02:00
Add release invokable to ScriptableResource
This commit is contained in:
parent
825431829d
commit
5ec82fa43d
2 changed files with 19 additions and 6 deletions
|
@ -123,13 +123,13 @@ ScriptableResource::ScriptableResource(const QUrl& url) :
|
||||||
QObject(nullptr),
|
QObject(nullptr),
|
||||||
_url(url) {}
|
_url(url) {}
|
||||||
|
|
||||||
|
void ScriptableResource::release() {
|
||||||
|
disconnectHelper();
|
||||||
|
_resource.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptableResource::finished(bool success) {
|
void ScriptableResource::finished(bool success) {
|
||||||
if (_progressConnection) {
|
disconnectHelper();
|
||||||
disconnect(_progressConnection);
|
|
||||||
}
|
|
||||||
if (_finishedConnection) {
|
|
||||||
disconnect(_finishedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
_isFailed = !success;
|
_isFailed = !success;
|
||||||
|
@ -140,6 +140,15 @@ void ScriptableResource::finished(bool success) {
|
||||||
emit loadedChanged(_isLoaded);
|
emit loadedChanged(_isLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptableResource::disconnectHelper() {
|
||||||
|
if (_progressConnection) {
|
||||||
|
disconnect(_progressConnection);
|
||||||
|
}
|
||||||
|
if (_finishedConnection) {
|
||||||
|
disconnect(_finishedConnection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ScriptableResource* ResourceCache::prefetch(const QUrl& url, void* extra) {
|
ScriptableResource* ResourceCache::prefetch(const QUrl& url, void* extra) {
|
||||||
auto result = new ScriptableResource(url);
|
auto result = new ScriptableResource(url);
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,8 @@ public:
|
||||||
ScriptableResource(const QUrl& url);
|
ScriptableResource(const QUrl& url);
|
||||||
virtual ~ScriptableResource() = default;
|
virtual ~ScriptableResource() = default;
|
||||||
|
|
||||||
|
Q_INVOKABLE void release();
|
||||||
|
|
||||||
const QUrl& getUrl() const { return _url; }
|
const QUrl& getUrl() const { return _url; }
|
||||||
bool isLoaded() const { return _isLoaded; }
|
bool isLoaded() const { return _isLoaded; }
|
||||||
bool isFailed() const { return _isFailed; }
|
bool isFailed() const { return _isFailed; }
|
||||||
|
@ -102,6 +104,8 @@ private slots:
|
||||||
void finished(bool success);
|
void finished(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void disconnectHelper();
|
||||||
|
|
||||||
friend class ResourceCache;
|
friend class ResourceCache;
|
||||||
|
|
||||||
// Holds a ref to the resource to keep it in scope
|
// Holds a ref to the resource to keep it in scope
|
||||||
|
|
Loading…
Reference in a new issue