mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 09:13:10 +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),
|
||||
_url(url) {}
|
||||
|
||||
void ScriptableResource::release() {
|
||||
disconnectHelper();
|
||||
_resource.reset();
|
||||
}
|
||||
|
||||
void ScriptableResource::finished(bool success) {
|
||||
if (_progressConnection) {
|
||||
disconnect(_progressConnection);
|
||||
}
|
||||
if (_finishedConnection) {
|
||||
disconnect(_finishedConnection);
|
||||
}
|
||||
disconnectHelper();
|
||||
|
||||
_isLoaded = true;
|
||||
_isFailed = !success;
|
||||
|
@ -140,6 +140,15 @@ void ScriptableResource::finished(bool success) {
|
|||
emit loadedChanged(_isLoaded);
|
||||
}
|
||||
|
||||
void ScriptableResource::disconnectHelper() {
|
||||
if (_progressConnection) {
|
||||
disconnect(_progressConnection);
|
||||
}
|
||||
if (_finishedConnection) {
|
||||
disconnect(_finishedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
ScriptableResource* ResourceCache::prefetch(const QUrl& url, void* extra) {
|
||||
auto result = new ScriptableResource(url);
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ public:
|
|||
ScriptableResource(const QUrl& url);
|
||||
virtual ~ScriptableResource() = default;
|
||||
|
||||
Q_INVOKABLE void release();
|
||||
|
||||
const QUrl& getUrl() const { return _url; }
|
||||
bool isLoaded() const { return _isLoaded; }
|
||||
bool isFailed() const { return _isFailed; }
|
||||
|
@ -102,6 +104,8 @@ private slots:
|
|||
void finished(bool success);
|
||||
|
||||
private:
|
||||
void disconnectHelper();
|
||||
|
||||
friend class ResourceCache;
|
||||
|
||||
// Holds a ref to the resource to keep it in scope
|
||||
|
|
Loading…
Reference in a new issue