summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2017-01-15 12:54:46 +0100
committerMattes D <github@xoft.cz>2017-01-15 12:54:58 +0100
commite9547101b1d95167657a9b470eef1f0029fcb7e6 (patch)
treee51cadb2a18e6c50d77aaac4554af427de067b92 /src/Bindings/LuaState.cpp
parentMoved cPrefab parser self-check to the LoadablePieces test. (#3536) (diff)
downloadcuberite-e9547101b1d95167657a9b470eef1f0029fcb7e6.tar
cuberite-e9547101b1d95167657a9b470eef1f0029fcb7e6.tar.gz
cuberite-e9547101b1d95167657a9b470eef1f0029fcb7e6.tar.bz2
cuberite-e9547101b1d95167657a9b470eef1f0029fcb7e6.tar.lz
cuberite-e9547101b1d95167657a9b470eef1f0029fcb7e6.tar.xz
cuberite-e9547101b1d95167657a9b470eef1f0029fcb7e6.tar.zst
cuberite-e9547101b1d95167657a9b470eef1f0029fcb7e6.zip
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r--src/Bindings/LuaState.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index b768b21a3..2acf7df84 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -2288,15 +2288,17 @@ void cLuaState::UntrackRef(cTrackedRef & a_Ref)
return;
}
- // Remove the callback:
+ // Remove the callback (note that another thread may have cleared the callbacks by closing the LuaState):
cCSLock Lock(canonState->m_CSTrackedRefs);
auto & trackedRefs = canonState->m_TrackedRefs;
- trackedRefs.erase(std::remove_if(trackedRefs.begin(), trackedRefs.end(),
- [&a_Ref](cTrackedRef * a_StoredRef)
+ for (auto itr = trackedRefs.begin(), end = trackedRefs.end(); itr != end; ++itr)
+ {
+ if (*itr == &a_Ref)
{
- return (a_StoredRef == &a_Ref);
+ trackedRefs.erase(itr);
+ break;
}
- ));
+ }
}