Skip to content

Commit b89c79e

Browse files
committedJun 3, 2013
Delay deleting replaced textures (m_texture_trash)
1 parent 9fe74a3 commit b89c79e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed
 

‎src/tile.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ class TextureSource : public IWritableTextureSource
440440

441441
// Queued texture fetches (to be processed by the main thread)
442442
RequestQueue<std::string, u32, u8, u8> m_get_texture_queue;
443+
444+
// Textures that have been overwritten with other ones
445+
// but can't be deleted because the ITexture* might still be used
446+
std::list<video::ITexture*> m_texture_trash;
443447
};
444448

445449
IWritableTextureSource* createTextureSource(IrrlichtDevice *device)
@@ -485,6 +489,16 @@ TextureSource::~TextureSource()
485489
}
486490
m_atlaspointer_cache.clear();
487491

492+
for (std::list<video::ITexture*>::iterator iter =
493+
m_texture_trash.begin(); iter != m_texture_trash.end();
494+
iter++)
495+
{
496+
video::ITexture *t = *iter;
497+
498+
//cleanup trashed texture
499+
driver->removeTexture(t);
500+
}
501+
488502
infostream << "~TextureSource() "<< textures_before << "/"
489503
<< driver->getTextureCount() << std::endl;
490504
}
@@ -870,7 +884,7 @@ void TextureSource::rebuildImagesAndTextures()
870884
sap->intsize = img->getDimension();
871885

872886
if (t_old != 0)
873-
driver->removeTexture(t_old);
887+
m_texture_trash.push_back(t_old);
874888
}
875889
}
876890

0 commit comments

Comments
 (0)