Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 4 files). Show all
Unified · Split
| @@ -156,31 +156,30 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) { · 155 unmodified lines | |||
| 156 | if (_isRunning) { | 156 | if (_isRunning) { |
| 157 | return; | 157 | return; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | QString scriptURLString = scriptURL.toString(); | 160 | _fileNameString = scriptURL.toString(); |
| 161 | _fileNameString = scriptURLString; | ||
| 162 | 161 | ||
| 163 | QUrl url(scriptURL); | 162 | QUrl url(scriptURL); |
| 164 | 163 | ||
| 165 | // if the scheme length is one or lower, maybe they typed in a file, let's try | 164 | // if the scheme length is one or lower, maybe they typed in a file, let's try |
| 166 | const int WINDOWS_DRIVE_LETTER_SIZE = 1; | 165 | const int WINDOWS_DRIVE_LETTER_SIZE = 1; |
| 167 | if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) { | 166 | if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) { |
| 168 | url = QUrl::fromLocalFile(scriptURLString); | 167 | url = QUrl::fromLocalFile(_fileNameString); |
| 169 | } | 168 | } |
| 170 | 169 | ||
| 171 | // ok, let's see if it's valid... and if so, load it | 170 | // ok, let's see if it's valid... and if so, load it |
| 172 | if (url.isValid()) { | 171 | if (url.isValid()) { |
| 173 | if (url.scheme() == "file") { | 172 | if (url.scheme() == "file") { |
| 174 | QString fileName = url.toLocalFile(); | 173 | _fileNameString = url.toLocalFile(); |
| 175 | QFile scriptFile(fileName); | 174 | QFile scriptFile(_fileNameString); |
| 176 | if (scriptFile.open(QFile::ReadOnly | QFile::Text)) { | 175 | if (scriptFile.open(QFile::ReadOnly | QFile::Text)) { |
| 177 | qDebug() << "Loading file:" << fileName; | 176 | qDebug() << "ScriptEngine loading file:" << _fileNameString; |
| 178 | QTextStream in(&scriptFile); | 177 | QTextStream in(&scriptFile); |
| 179 | _scriptContents = in.readAll(); | 178 | _scriptContents = in.readAll(); |
| 180 | emit scriptLoaded(url); | 179 | emit scriptLoaded(_fileNameString); |
| 181 | } else { | 180 | } else { |
| 182 | qDebug() << "ERROR Loading file:" << fileName; | 181 | qDebug() << "ERROR Loading file:" << _fileNameString; |
| 183 | emit errorLoadingScript(url); | 182 | emit errorLoadingScript(_fileNameString); |
| 184 | } | 183 | } |
| 185 | } else { | 184 | } else { |
| 186 | QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); | 185 | QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); |
| @@ -195,10 +194,10 @@ void ScriptEngine::handleScriptDownload() { · 8 unmodified lines | |||
| 195 | 194 | ||
| 196 | if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) { | 195 | if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) { |
| 197 | _scriptContents = reply->readAll(); | 196 | _scriptContents = reply->readAll(); |
| 198 | emit scriptLoaded(reply->url()); | 197 | emit scriptLoaded(_fileNameString); |
| 199 | } else { | 198 | } else { |
| 200 | qDebug() << "ERROR Loading file:" << reply->url().toString(); | 199 | qDebug() << "ERROR Loading file:" << reply->url().toString(); |
| 201 | emit errorLoadingScript(reply->url()); | 200 | emit errorLoadingScript(_fileNameString); |
| 202 | } | 201 | } |
| 203 | } | 202 | } |
| 204 | 203 | ||