Skip to content

Commit 97a1171

Browse files
committed
Some cleanup. might as well do this all-in-one. Also fix crash with GC during script reload
1 parent 2d1c64b commit 97a1171

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

Managers/LuaMan.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,21 @@ namespace RTE {
395395
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
396396

397397
void LuaMan::ClearUserModuleCache() {
398+
if (m_GCThread.joinable()) {
399+
m_GCThread.join();
400+
}
401+
402+
m_ScriptThreadSafetyMap.clear();
403+
404+
m_MasterScriptState.ClearLuaScriptCache();
405+
for (LuaStateWrapper& luaState : m_ScriptStates) {
406+
luaState.ClearLuaScriptCache();
407+
}
408+
398409
m_MasterScriptState.ClearUserModuleCache();
399-
for (LuaStateWrapper &luaState : m_ScriptStates) {
410+
for (LuaStateWrapper& luaState : m_ScriptStates) {
400411
luaState.ClearUserModuleCache();
401412
}
402-
m_ScriptThreadSafetyMap.clear();
403413
}
404414

405415
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -439,16 +449,6 @@ namespace RTE {
439449
return timings;
440450
}
441451

442-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
443-
444-
void LuaMan::ClearLuaScriptCache() {
445-
m_ScriptThreadSafetyMap.clear();
446-
m_MasterScriptState.ClearLuaScriptCache();
447-
for (LuaStateWrapper &luaState : m_ScriptStates) {
448-
luaState.ClearLuaScriptCache();
449-
}
450-
}
451-
452452
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
453453

454454
void LuaMan::Destroy() {

Managers/LuaMan.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,6 @@ namespace RTE {
412412
/// </summary>
413413
/// <returns>m_ScriptTimings.</returns>
414414
const std::unordered_map<std::string, PerformanceMan::ScriptTiming> GetScriptTimings() const;
415-
416-
/// <summary>
417-
/// Clears the Lua script cache.
418-
/// </summary>
419-
void ClearLuaScriptCache();
420415
#pragma endregion
421416

422417
#pragma region File I/O Handling

Managers/PresetMan.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ std::string PresetMan::GetEntityDataLocation(std::string type, std::string prese
908908

909909
void PresetMan::ReloadAllScripts() const {
910910
g_LuaMan.ClearUserModuleCache();
911-
g_LuaMan.ClearLuaScriptCache();
912911
for (const DataModule *dataModule : m_pDataModules) {
913912
dataModule->ReloadAllScripts();
914913
}

0 commit comments

Comments
 (0)