Merge pull request #3036 from huffman/19788

Code Review for Job #19788
This commit is contained in:
Brad Hefta-Gaub 2014-06-17 16:28:03 -07:00
commit df27de3c73
2 changed files with 8 additions and 2 deletions

View file

@ -3523,12 +3523,13 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript
} else { } else {
// start the script on a new thread... // start the script on a new thread...
scriptEngine = new ScriptEngine(scriptUrl, &_controllerScriptingInterface); scriptEngine = new ScriptEngine(scriptUrl, &_controllerScriptingInterface);
_scriptEnginesHash.insert(scriptURLString, scriptEngine);
if (!scriptEngine->hasScript()) { if (!scriptEngine->hasScript()) {
qDebug() << "Application::loadScript(), script failed to load..."; qDebug() << "Application::loadScript(), script failed to load...";
return NULL; return NULL;
} }
_scriptEnginesHash.insert(scriptURLString, scriptEngine);
_runningScriptsWidget->setRunningScripts(getRunningScripts()); _runningScriptsWidget->setRunningScripts(getRunningScripts());
} }

View file

@ -147,7 +147,12 @@ ScriptEngine::ScriptEngine(const QUrl& scriptURL,
QEventLoop loop; QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec(); loop.exec();
_scriptContents = reply->readAll(); if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
_scriptContents = reply->readAll();
} else {
qDebug() << "ERROR Loading file:" << url.toString();
emit errorMessage("ERROR Loading file:" + url.toString());
}
} }
} }
} }