From 116c220ca52745424301f78bcf1759f969fb985e Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Fri, 22 Nov 2013 15:14:51 +0100 Subject: [PATCH] Added destructor to renderlist::DataBase --- include/tinia/renderlist/DataBase.hpp | 2 ++ src/renderlist/DataBase.cpp | 34 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/tinia/renderlist/DataBase.hpp b/include/tinia/renderlist/DataBase.hpp index d5d657e..1ef0db9 100644 --- a/include/tinia/renderlist/DataBase.hpp +++ b/include/tinia/renderlist/DataBase.hpp @@ -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. diff --git a/src/renderlist/DataBase.cpp b/src/renderlist/DataBase.cpp index 39d6d7e..90ea029 100644 --- a/src/renderlist/DataBase.cpp +++ b/src/renderlist/DataBase.cpp @@ -603,5 +603,39 @@ DataBase::bump( ) return m_current_rev++; } +DataBase::~DataBase() +{ + for(std::map::iterator it = m_name_map.begin(); it != m_name_map.end(); ++it) { + delete it->second; + } + + std::vector shadersToDelete; + for(std::map::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 actionsToDelete; + for(std::map::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 buffersToDelete; + for(std::map::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