* Unload scripts that are auto-refreshing before restarting them. (#1697) * Refactors `entityScriptChanging` to account for old and new URLs, was previously always setting them both to `""` and failing. (#2187) * Cleaned up `EntityTreeRenderer::checkAndCallPreload` to be less confusing lol
Showing the changes to libraries/script-engine/src/ScriptManager.cpp (1 of 9 files). Show all
Unified · Split
| @@ -2658,11 +2658,10 @@ void ScriptManager::refreshFileScript(const EntityItemID& entityID, const QStrin · 2657 unmodified lines | |||
| 2658 | return; | 2658 | return; |
| 2659 | } | 2659 | } |
| 2660 | 2660 | ||
| 2661 | static bool recurseGuard = false; | 2661 | if (_refreshRecurseGuard) { |
| 2662 | if (recurseGuard) { | ||
| 2663 | return; | 2662 | return; |
| 2664 | } | 2663 | } |
| 2665 | recurseGuard = true; | 2664 | _refreshRecurseGuard = true; |
| 2666 | 2665 | ||
| 2667 | EntityScriptDetails details; | 2666 | EntityScriptDetails details; |
| 2668 | { | 2667 | { |
| @@ -2675,10 +2674,11 @@ void ScriptManager::refreshFileScript(const EntityItemID& entityID, const QStrin · 6 unmodified lines | |||
| 2675 | auto lastModified = QFileInfo(filePath).lastModified().toMSecsSinceEpoch(); | 2674 | auto lastModified = QFileInfo(filePath).lastModified().toMSecsSinceEpoch(); |
| 2676 | if (lastModified > details.lastModified) { | 2675 | if (lastModified > details.lastModified) { |
| 2677 | scriptInfoMessage("Reloading modified script " + details.scriptText, filePath, -1); | 2676 | scriptInfoMessage("Reloading modified script " + details.scriptText, filePath, -1); |
| 2677 | unloadEntityScript(entityID, details.scriptText, true); | ||
| 2678 | loadEntityScript(entityID, details.scriptText, true); | 2678 | loadEntityScript(entityID, details.scriptText, true); |
| 2679 | } | 2679 | } |
| 2680 | } | 2680 | } |
| 2681 | recurseGuard = false; | 2681 | _refreshRecurseGuard = false; |
| 2682 | } | 2682 | } |
| 2683 | 2683 | ||
| 2684 | // Execute operation in the appropriate context for (the possibly empty) entityID. | 2684 | // Execute operation in the appropriate context for (the possibly empty) entityID. |