History

don't block main thread for a script load

Stephen Birarda committed 11 years ago

Commit d7f16891 parent 36f716c4 files · +39 −22Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+4−3
@@ -177,10 +177,10 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) { · 176 unmodified lines
177 qDebug() << "Loading file:" << fileName;177 qDebug() << "Loading file:" << fileName;
178 QTextStream in(&scriptFile);178 QTextStream in(&scriptFile);
179 _scriptContents = in.readAll();179 _scriptContents = in.readAll();
180 emit scriptLoaded();180 emit scriptLoaded(url);
181 } else {181 } else {
182 qDebug() << "ERROR Loading file:" << fileName;182 qDebug() << "ERROR Loading file:" << fileName;
183 emit errorLoadingScript();183 emit errorLoadingScript(url);
184 }184 }
185 } else {185 } else {
186 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();186 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
@@ -195,9 +195,10 @@ void ScriptEngine::handleScriptDownload() { · 8 unmodified lines
195 195
196 if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {196 if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
197 _scriptContents = reply->readAll();197 _scriptContents = reply->readAll();
198 emit scriptLoaded(reply->url());
198 } else {199 } else {
199 qDebug() << "ERROR Loading file:" << reply->url().toString();200 qDebug() << "ERROR Loading file:" << reply->url().toString();
200 emit errorLoadingScript();201 emit errorLoadingScript(reply->url());
201 }202 }
202}203}
203 204