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:
Chris Collins 2016-10-06 11:46:19 -07:00 committed by GitHub
commit aecf71a0d0
2 changed files with 17 additions and 1 deletions

View file

@ -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 {
if (callback.isFunction()) {
QString url = "atp:" + hash;
QScriptValueList args { url };
QScriptValueList args { url, hash };
callback.call(_engine->currentContext()->thisObject(), args);
}
upload->deleteLater();
});
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) {
const QString ATP_SCHEME { "atp:" };

View file

@ -26,6 +26,7 @@ public:
Q_INVOKABLE void uploadData(QString data, QScriptValue callback);
Q_INVOKABLE void downloadData(QString url, QScriptValue downloadComplete);
Q_INVOKABLE void setMapping(QString path, QString hash, QScriptValue callback);
protected:
QSet<AssetRequest*> _pendingRequests;