History

Make individual reload buttons reload scripts

David Rowe committed 11 years ago

Commit 67206331 parent 2a005868 files · +53 −30Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+11−4
@@ -94,6 +94,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 93 unmodified lines
94 _vec3Library(),94 _vec3Library(),
95 _uuidLibrary(),95 _uuidLibrary(),
96 _isUserLoaded(false),96 _isUserLoaded(false),
97 _isReloading(false),
97 _arrayBufferClass(new ArrayBufferClass(this))98 _arrayBufferClass(new ArrayBufferClass(this))
98{99{
99 _allScriptsMutex.lock();100 _allScriptsMutex.lock();
@@ -251,12 +252,13 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents, const QStrin · 151 unmodified lines
251 return true;252 return true;
252}253}
253 254
254void ScriptEngine::loadURL(const QUrl& scriptURL) {255void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
255 if (_isRunning) {256 if (_isRunning) {
256 return;257 return;
257 }258 }
258 259
259 _fileNameString = scriptURL.toString();260 _fileNameString = scriptURL.toString();
261 _isReloading = reload;
260 262
261 QUrl url(scriptURL);263 QUrl url(scriptURL);
262 264
@@ -283,8 +285,7 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) { · 20 unmodified lines
283 } else {285 } else {
284 bool isPending;286 bool isPending;
285 auto scriptCache = DependencyManager::get<ScriptCache>();287 auto scriptCache = DependencyManager::get<ScriptCache>();
286 scriptCache->getScript(url, this, isPending);288 scriptCache->getScript(url, this, isPending, reload);
287
288 }289 }
289 }290 }
290}291}
@@ -901,7 +902,13 @@ void ScriptEngine::load(const QString& loadFile) { · 610 unmodified lines
901 }902 }
902 903
903 QUrl url = resolvePath(loadFile);904 QUrl url = resolvePath(loadFile);
904 emit loadScript(url.toString(), false);905 if (_isReloading) {
906 auto scriptCache = DependencyManager::get<ScriptCache>();
907 scriptCache->deleteScript(url.toString());
908 emit reloadScript(url.toString(), false);
909 } else {
910 emit loadScript(url.toString(), false);
911 }
905}912}
906 913
907void ScriptEngine::nodeKilled(SharedNodePointer node) {914void ScriptEngine::nodeKilled(SharedNodePointer node) {