mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:09:56 +02:00
Merge pull request #8729 from huffman/feat/atp-set-mapping
Add setMapping to ATP scripting interface and fix threading bug
This commit is contained in:
commit
aecf71a0d0
2 changed files with 17 additions and 1 deletions
|
@ -31,13 +31,28 @@ void AssetScriptingInterface::uploadData(QString data, QScriptValue callback) {
|
||||||
QObject::connect(upload, &AssetUpload::finished, this, [this, callback](AssetUpload* upload, const QString& hash) mutable {
|
QObject::connect(upload, &AssetUpload::finished, this, [this, callback](AssetUpload* upload, const QString& hash) mutable {
|
||||||
if (callback.isFunction()) {
|
if (callback.isFunction()) {
|
||||||
QString url = "atp:" + hash;
|
QString url = "atp:" + hash;
|
||||||
QScriptValueList args { url };
|
QScriptValueList args { url, hash };
|
||||||
callback.call(_engine->currentContext()->thisObject(), args);
|
callback.call(_engine->currentContext()->thisObject(), args);
|
||||||
}
|
}
|
||||||
|
upload->deleteLater();
|
||||||
});
|
});
|
||||||
upload->start();
|
upload->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetScriptingInterface::setMapping(QString path, QString hash, QScriptValue callback) {
|
||||||
|
auto setMappingRequest = DependencyManager::get<AssetClient>()->createSetMappingRequest(path, hash);
|
||||||
|
|
||||||
|
QObject::connect(setMappingRequest, &SetMappingRequest::finished, this, [this, callback](SetMappingRequest* request) mutable {
|
||||||
|
if (callback.isFunction()) {
|
||||||
|
QScriptValueList args { };
|
||||||
|
callback.call(_engine->currentContext()->thisObject(), args);
|
||||||
|
}
|
||||||
|
request->deleteLater();
|
||||||
|
});
|
||||||
|
setMappingRequest->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AssetScriptingInterface::downloadData(QString urlString, QScriptValue callback) {
|
void AssetScriptingInterface::downloadData(QString urlString, QScriptValue callback) {
|
||||||
const QString ATP_SCHEME { "atp:" };
|
const QString ATP_SCHEME { "atp:" };
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void uploadData(QString data, QScriptValue callback);
|
Q_INVOKABLE void uploadData(QString data, QScriptValue callback);
|
||||||
Q_INVOKABLE void downloadData(QString url, QScriptValue downloadComplete);
|
Q_INVOKABLE void downloadData(QString url, QScriptValue downloadComplete);
|
||||||
|
Q_INVOKABLE void setMapping(QString path, QString hash, QScriptValue callback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSet<AssetRequest*> _pendingRequests;
|
QSet<AssetRequest*> _pendingRequests;
|
||||||
|
|
Loading…
Reference in a new issue