History

normalize how ScriptCache::getScript() works relative to ResourceManager

Brad Hefta-Gaub committed 11 years ago

Commit 8395fb61 parent f85cb2c5 files · +28 −47Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 5 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+3−35
@@ -275,8 +275,6 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents, const QStrin · 274 unmodified lines
275275
276276 // FIXME - remove the file/url scheme code here and let the script cache handle things
277277 void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
278− qDebug() << "ScriptEngine::loadURL(" << scriptURL << ", " << reload << ");";
279−
280278 if (_isRunning) {
281279 return;
282280 }
@@ -286,39 +284,9 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { · 3 unmodified lines
286284
287285 QUrl url(scriptURL);
288286
289− // if the scheme length is one or lower, maybe they typed in a file, let's try
290− const int WINDOWS_DRIVE_LETTER_SIZE = 1;
291− if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) {
292− url = QUrl::fromLocalFile(_fileNameString);
293− }
294−
295− // ok, let's see if it's valid... and if so, load it
296− if (url.isValid()) {
297− if (url.scheme() == "file") {
298− _fileNameString = url.toLocalFile();
299− QFile scriptFile(_fileNameString);
300− if (scriptFile.open(QFile::ReadOnly | QFile::Text)) {
301− qCDebug(scriptengine) << "ScriptEngine loading file:" << _fileNameString;
302− QTextStream in(&scriptFile);
303− _scriptContents = in.readAll();
304− if (_wantSignals) {
305− emit scriptLoaded(_fileNameString);
306− }
307− } else {
308− qCDebug(scriptengine) << "ERROR Loading file:" << _fileNameString << "line:" << __LINE__;
309− if (_wantSignals) {
310− emit errorLoadingScript(_fileNameString);
311− }
312− }
313− } else {
314− bool isPending;
315− auto scriptCache = DependencyManager::get<ScriptCache>();
316− qDebug() << "calling scriptCache->getScript(" << url << ", " << reload << ");";
317− scriptCache->getScript(url, this, isPending, reload);
318− qDebug() << " scriptCache->getScript(" << url << ", " << reload << ") ... isPending:" << isPending;
319−
320− }
321− }
287+ bool isPending;
288+ auto scriptCache = DependencyManager::get<ScriptCache>();
289+ scriptCache->getScript(url, this, isPending, reload);
322290 }
323291
324292 void ScriptEngine::scriptContentsAvailable(const QUrl& url, const QString& scriptContents) {