apply Huffman's feedback to Sam's PR

This commit is contained in:
Brad Hefta-Gaub 2015-10-17 12:34:32 -07:00
parent fd5a5bb104
commit f90f0ed1f3
2 changed files with 5 additions and 3 deletions

View file

@ -70,7 +70,7 @@ mapping2.enable();
Controller.enableMapping("example2");
*/
var mapping3 = Controller.loadMapping("E:/Github/hifi/examples/controllers/example3.json");
var mapping3 = Controller.loadMapping(Script.resolvePath("example3.json"));
Controller.enableMapping("example3");
/*

View file

@ -209,6 +209,7 @@ namespace controller {
}
QObject* ScriptingInterface::loadMapping(const QString& jsonUrl) {
QObject* result = nullptr;
auto request = ResourceManager::createResourceRequest(nullptr, QUrl(jsonUrl));
if (request) {
QEventLoop eventLoop;
@ -220,12 +221,13 @@ namespace controller {
}
if (request->getResult() == ResourceRequest::Success) {
return parseMapping(QString(request->getData()));
result = parseMapping(QString(request->getData()));
} else {
qDebug() << "Failed to load mapping url <" << jsonUrl << ">" << endl;
return nullptr;
}
request->deleteLater();
}
return result;
}
Q_INVOKABLE QObject* newMapping(const QJsonObject& json);