Skip to content

Commit

Permalink
Added destructor to renderlist::DataBase
Browse files Browse the repository at this point in the history
  • Loading branch information
kjetilly committed Nov 22, 2013
1 parent 3912c33 commit 116c220
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/tinia/renderlist/DataBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class DataBase
public:
DataBase();

~DataBase();

/** Fetch an item (shader,buffer,image,action) by name.
*
* \returns The item or null if no item is found.
Expand Down
34 changes: 34 additions & 0 deletions src/renderlist/DataBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,5 +603,39 @@ DataBase::bump( )
return m_current_rev++;
}

DataBase::~DataBase()
{
for(std::map<std::string, Item*>::iterator it = m_name_map.begin(); it != m_name_map.end(); ++it) {
delete it->second;
}

std::vector<Id> shadersToDelete;
for(std::map<Id, Shader*>::iterator it = m_shaders.begin(); it != m_shaders.end(); ++it) {
shadersToDelete.push_back(it->first);
}

for(size_t i = 0; i < shadersToDelete.size(); ++i) {
deleteShader(shadersToDelete[i]);
}

std::vector<Id> actionsToDelete;
for(std::map<Id, Action*>::iterator it = m_actions.begin(); it != m_actions.end(); ++it) {
actionsToDelete.push_back(it->first);
}

for(size_t i = 0; i < actionsToDelete.size(); ++i) {
deleteAction(actionsToDelete[i]);
}

std::vector<Id> buffersToDelete;
for(std::map<Id, Buffer*>::iterator it = m_buffers.begin(); it != m_buffers.end(); ++it) {
buffersToDelete.push_back(it->first);
}

for(size_t i = 0; i < buffersToDelete.size(); ++i) {
deleteBuffer(buffersToDelete[i]);
}
}

} // of namespace renderlist
} // of namespace tinia

0 comments on commit 116c220

Please sign in to comment.