Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
fix extruded items texture leak
Browse files Browse the repository at this point in the history
  • Loading branch information
sapier authored and sapier committed Apr 7, 2013
1 parent 4468ea8 commit 6b256e8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/itemdef.cpp
Expand Up @@ -228,6 +228,7 @@ class CItemDefManager: public IWritableItemDefManager
{
#ifndef SERVER
m_main_thread = get_current_thread_id();
m_driver = NULL;
#endif

clear();
Expand All @@ -242,6 +243,14 @@ class CItemDefManager: public IWritableItemDefManager
ClientCached *cc = *i;
cc->wield_mesh->drop();
}

if (m_driver != NULL) {
for (unsigned int i = 0; i < m_extruded_textures.size(); i++) {
m_driver->removeTexture(m_extruded_textures[i]);
}
m_extruded_textures.clear();
}
m_driver = NULL;
#endif
}
virtual const ItemDefinition& get(const std::string &name_) const
Expand Down Expand Up @@ -290,6 +299,10 @@ class CItemDefManager: public IWritableItemDefManager
return m_item_definitions.find(name) != m_item_definitions.end();
}
#ifndef SERVER
private:
static video::IVideoDriver * m_driver;
static std::vector<video::ITexture*> m_extruded_textures;
public:
ClientCached* createClientCachedDirect(const std::string &name,
IGameDef *gamedef) const
{
Expand Down Expand Up @@ -432,6 +445,13 @@ class CItemDefManager: public IWritableItemDefManager
tsrc->getTextureRaw(f.tiledef[0].name);
}
}
else
{
if (m_driver == 0)
m_driver = driver;

m_extruded_textures.push_back(cc->inventory_texture);
}

/*
Use the node mesh as the wield mesh
Expand Down Expand Up @@ -658,3 +678,8 @@ IWritableItemDefManager* createItemDefManager()
return new CItemDefManager();
}

#ifndef SERVER
//TODO very very very dirty hack!
video::IVideoDriver * CItemDefManager::m_driver = 0;
std::vector<video::ITexture*> CItemDefManager::m_extruded_textures;
#endif

0 comments on commit 6b256e8

Please sign in to comment.