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
9494 _vec3Library(),
9595 _uuidLibrary(),
9696 _isUserLoaded(false),
97+ _isReloading(false),
9798 _arrayBufferClass(new ArrayBufferClass(this))
9899 {
99100 _allScriptsMutex.lock();
@@ -251,12 +252,13 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents, const QStrin · 151 unmodified lines
251252 return true;
252253 }
253254
254−void ScriptEngine::loadURL(const QUrl& scriptURL) {
255+void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
255256 if (_isRunning) {
256257 return;
257258 }
258259
259260 _fileNameString = scriptURL.toString();
261+ _isReloading = reload;
260262
261263 QUrl url(scriptURL);
262264
@@ -283,8 +285,7 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) { · 20 unmodified lines
283285 } else {
284286 bool isPending;
285287 auto scriptCache = DependencyManager::get<ScriptCache>();
286− scriptCache->getScript(url, this, isPending);
287−
288+ scriptCache->getScript(url, this, isPending, reload);
288289 }
289290 }
290291 }
@@ -901,7 +902,13 @@ void ScriptEngine::load(const QString& loadFile) { · 610 unmodified lines
901902 }
902903
903904 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+ }
905912 }
906913
907914 void ScriptEngine::nodeKilled(SharedNodePointer node) {