diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index c9fe8fa6..133a6ef8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -435,8 +435,14 @@ namespace PolyVox void LargeVolume::flushAll() { typename CompressedBlockMap::iterator i; + //Replaced the for loop here as the call to //eraseBlock was invalidating the iterator. + while(m_pUncompressedBlockCache.size() > 0) + { + eraseBlock(m_pUncompressedBlockCache.begin()); + } + while(m_pBlocks.size() > 0) { eraseBlock(m_pBlocks.begin());