TileGenerator: free database resources (#38)

Destructor of DB* instance was never called.
Ensure it is, adding missing base class virtual destructor and calling delete when possible to free resources.
This commit is contained in:
Nestorfish
2016-10-13 23:26:59 +02:00
committed by sfan5
parent d83f0d9e8d
commit 26b62933ed
6 changed files with 15 additions and 4 deletions

View File

@ -110,7 +110,8 @@ TileGenerator::TileGenerator():
m_shading(true),
m_backend(""),
m_border(0),
m_image(0),
m_db(NULL),
m_image(NULL),
m_xMin(INT_MAX),
m_xMax(INT_MIN),
m_zMin(INT_MAX),
@ -127,6 +128,7 @@ TileGenerator::TileGenerator():
TileGenerator::~TileGenerator()
{
closeDatabase();
}
void TileGenerator::setBgColor(const std::string &bgColor)
@ -246,6 +248,7 @@ void TileGenerator::generate(const std::string &input, const std::string &output
loadBlocks();
createImage();
renderMap();
closeDatabase();
if (m_drawScale) {
renderScale();
}
@ -314,6 +317,12 @@ void TileGenerator::openDb(const std::string &input)
throw std::runtime_error(((std::string) "Unknown map backend: ") + backend);
}
void TileGenerator::closeDatabase()
{
delete m_db;
m_db = NULL;
}
void TileGenerator::loadBlocks()
{
std::vector<BlockPos> vec = m_db->getBlockPos();