From 34cf058b0257587456632536a54db0d4e119dae1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Apr 2014 22:35:04 +0200 Subject: [PATCH] ChunkStay must be disabled while being deleted. Fixes #758. --- src/ChunkStay.cpp | 5 +---- src/ChunkStay.h | 4 ++++ src/LightingThread.cpp | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ChunkStay.cpp b/src/ChunkStay.cpp index a35ccf58c..b5002a63d 100644 --- a/src/ChunkStay.cpp +++ b/src/ChunkStay.cpp @@ -31,10 +31,7 @@ cChunkStay::~cChunkStay() void cChunkStay::Clear(void) { - if (m_ChunkMap != NULL) - { - Disable(); - } + ASSERT(m_ChunkMap == NULL); m_Chunks.clear(); } diff --git a/src/ChunkStay.h b/src/ChunkStay.h index 2510cb490..29893befc 100644 --- a/src/ChunkStay.h +++ b/src/ChunkStay.h @@ -36,8 +36,12 @@ class cChunkStay { public: cChunkStay(void); + + /** Deletes the object. Note that this calls Clear(), which means that the ChunkStay needs to be disabled. */ virtual ~cChunkStay(); + /** Clears all the chunks that have been added. + To be used only while the ChunkStay object is not enabled. */ void Clear(void); /** Adds a chunk to be locked from unloading. diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 302473d71..5ba2940d2 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -286,6 +286,7 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item) { a_Item.m_CallbackAfter->Call(a_Item.m_ChunkX, a_Item.m_ChunkZ); } + a_Item.Disable(); delete &a_Item; }