diff --git a/libraries/script-engine/src/BatchLoader.cpp b/libraries/script-engine/src/BatchLoader.cpp index f3e6242216..15b3b6c853 100644 --- a/libraries/script-engine/src/BatchLoader.cpp +++ b/libraries/script-engine/src/BatchLoader.cpp @@ -13,12 +13,14 @@ #include #include +#include #include "ScriptEngineLogging.h" #include "BatchLoader.h" #include #include #include "ResourceManager.h" #include "ScriptEngines.h" +#include "ScriptCache.h" BatchLoader::BatchLoader(const QList& urls) : QObject(), @@ -38,30 +40,25 @@ void BatchLoader::start() { for (const auto& rawURL : _urls) { QUrl url = expandScriptUrl(normalizeScriptURL(rawURL)); - auto request = ResourceManager::createResourceRequest(this, url); - if (!request) { - _data.insert(url, QString()); - qCDebug(scriptengine) << "Could not load" << url; - continue; - } - connect(request, &ResourceRequest::finished, this, [=]() { - if (request->getResult() == ResourceRequest::Success) { - _data.insert(url, request->getData()); + + qCDebug(scriptengine) << "Loading script at " << url; + + QPointer self = this; + DependencyManager::get()->getScriptContents(url.toString(), [this, self](const QString& url, const QString& contents, bool isURL, bool success) { + if (!self) { + return; + } + if (isURL && success) { + _data.insert(url, contents); + qCDebug(scriptengine) << "Loaded: " << url; } else { _data.insert(url, QString()); qCDebug(scriptengine) << "Could not load" << url; } - request->deleteLater(); checkFinished(); - }); - - // If we end up being destroyed before the reply finishes, clean it up - connect(this, &QObject::destroyed, request, &QObject::deleteLater); - - qCDebug(scriptengine) << "Loading script at " << url; - - request->send(); + }, false); } + checkFinished(); } diff --git a/libraries/script-engine/src/ScriptCache.cpp b/libraries/script-engine/src/ScriptCache.cpp index d8d75bce64..e9f20b5164 100644 --- a/libraries/script-engine/src/ScriptCache.cpp +++ b/libraries/script-engine/src/ScriptCache.cpp @@ -182,7 +182,6 @@ void ScriptCache::scriptContentAvailable() { if (success) { allCallbacks = scriptRequest.scriptUsers; - //auto scriptContent = _scriptCache[url]; _activeScriptRequests.remove(url);