Fix entity script destruction
Showing the changes to libraries/script-engine/src/ScriptManager.cpp (1 of 9 files). Show all
Unified · Split
| @@ -2665,11 +2665,10 @@ void ScriptManager::refreshFileScript(const EntityItemID& entityID, const QStrin · 2664 unmodified lines | ||
| 2665 | 2665 | return; |
| 2666 | 2666 | } |
| 2667 | 2667 | |
| 2668 | − static bool recurseGuard = false; | |
| 2669 | − if (recurseGuard) { | |
| 2668 | + if (_refreshRecurseGuard) { | |
| 2670 | 2669 | return; |
| 2671 | 2670 | } |
| 2672 | − recurseGuard = true; | |
| 2671 | + _refreshRecurseGuard = true; | |
| 2673 | 2672 | |
| 2674 | 2673 | EntityScriptDetails details; |
| 2675 | 2674 | { |
| @@ -2682,10 +2681,11 @@ void ScriptManager::refreshFileScript(const EntityItemID& entityID, const QStrin · 6 unmodified lines | ||
| 2682 | 2681 | auto lastModified = QFileInfo(filePath).lastModified().toMSecsSinceEpoch(); |
| 2683 | 2682 | if (lastModified > details.lastModified) { |
| 2684 | 2683 | scriptInfoMessage("Reloading modified script " + details.scriptText, filePath, -1); |
| 2684 | + unloadEntityScript(entityID, details.scriptText, true); | |
| 2685 | 2685 | loadEntityScript(entityID, details.scriptText, true); |
| 2686 | 2686 | } |
| 2687 | 2687 | } |
| 2688 | − recurseGuard = false; | |
| 2688 | + _refreshRecurseGuard = false; | |
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | // Execute operation in the appropriate context for (the possibly empty) entityID. |