mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 18:13:46 +01:00
Fixed minimap memory leak
This commit is contained in:
parent
9bc0241e44
commit
88a6b9f52d
@ -540,20 +540,19 @@ void Client::step(float dtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (r.mesh) {
|
if (r.mesh) {
|
||||||
minimap_mapblock = r.mesh->getMinimapMapblock();
|
minimap_mapblock = r.mesh->moveMinimapMapblock();
|
||||||
do_mapper_update = (minimap_mapblock != NULL);
|
if (minimap_mapblock == NULL)
|
||||||
|
do_mapper_update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.mesh && r.mesh->getMesh()->getMeshBufferCount() == 0) {
|
if (r.mesh && r.mesh->getMesh()->getMeshBufferCount() == 0) {
|
||||||
delete r.mesh;
|
delete r.mesh;
|
||||||
block->mesh = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
// Replace with the new mesh
|
// Replace with the new mesh
|
||||||
block->mesh = r.mesh;
|
block->mesh = r.mesh;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delete r.mesh;
|
delete r.mesh;
|
||||||
minimap_mapblock = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_mapper_update)
|
if (do_mapper_update)
|
||||||
|
@ -1278,6 +1278,7 @@ MapBlockMesh::~MapBlockMesh()
|
|||||||
{
|
{
|
||||||
m_mesh->drop();
|
m_mesh->drop();
|
||||||
m_mesh = NULL;
|
m_mesh = NULL;
|
||||||
|
delete m_minimap_mapblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_ratio)
|
bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_ratio)
|
||||||
|
@ -104,14 +104,16 @@ public:
|
|||||||
// Returns true if anything has been changed.
|
// Returns true if anything has been changed.
|
||||||
bool animate(bool faraway, float time, int crack, u32 daynight_ratio);
|
bool animate(bool faraway, float time, int crack, u32 daynight_ratio);
|
||||||
|
|
||||||
scene::SMesh* getMesh()
|
scene::SMesh *getMesh()
|
||||||
{
|
{
|
||||||
return m_mesh;
|
return m_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
MinimapMapblock* getMinimapMapblock()
|
MinimapMapblock *moveMinimapMapblock()
|
||||||
{
|
{
|
||||||
return m_minimap_mapblock;
|
MinimapMapblock *p = m_minimap_mapblock;
|
||||||
|
m_minimap_mapblock = NULL;
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAnimationForced() const
|
bool isAnimationForced() const
|
||||||
|
@ -102,7 +102,13 @@ void MinimapUpdateThread::doUpdate()
|
|||||||
|
|
||||||
while (popBlockUpdate(&update)) {
|
while (popBlockUpdate(&update)) {
|
||||||
if (update.data) {
|
if (update.data) {
|
||||||
m_blocks_cache[update.pos] = update.data;
|
// Swap two values in the map using single lookup
|
||||||
|
std::pair<std::map<v3s16, MinimapMapblock*>::iterator, bool>
|
||||||
|
result = m_blocks_cache.insert(std::make_pair(update.pos, update.data));
|
||||||
|
if (result.second == false) {
|
||||||
|
delete result.first->second;
|
||||||
|
result.first->second = update.data;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
std::map<v3s16, MinimapMapblock *>::iterator it;
|
std::map<v3s16, MinimapMapblock *>::iterator it;
|
||||||
it = m_blocks_cache.find(update.pos);
|
it = m_blocks_cache.find(update.pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user