Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 5 files). Show all
Unified · Split
| @@ -275,8 +275,6 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents, const QStrin · 274 unmodified lines | ||
| 275 | 275 | |
| 276 | 276 | // FIXME - remove the file/url scheme code here and let the script cache handle things |
| 277 | 277 | void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { |
| 278 | − qDebug() << "ScriptEngine::loadURL(" << scriptURL << ", " << reload << ");"; | |
| 279 | − | |
| 280 | 278 | if (_isRunning) { |
| 281 | 279 | return; |
| 282 | 280 | } |
| @@ -286,39 +284,9 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { · 3 unmodified lines | ||
| 286 | 284 | |
| 287 | 285 | QUrl url(scriptURL); |
| 288 | 286 | |
| 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); | |
| 322 | 290 | } |
| 323 | 291 | |
| 324 | 292 | void ScriptEngine::scriptContentsAvailable(const QUrl& url, const QString& scriptContents) { |