mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-11-26 01:13:55 +01:00
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:
parent
d83f0d9e8d
commit
26b62933ed
@ -110,7 +110,8 @@ TileGenerator::TileGenerator():
|
|||||||
m_shading(true),
|
m_shading(true),
|
||||||
m_backend(""),
|
m_backend(""),
|
||||||
m_border(0),
|
m_border(0),
|
||||||
m_image(0),
|
m_db(NULL),
|
||||||
|
m_image(NULL),
|
||||||
m_xMin(INT_MAX),
|
m_xMin(INT_MAX),
|
||||||
m_xMax(INT_MIN),
|
m_xMax(INT_MIN),
|
||||||
m_zMin(INT_MAX),
|
m_zMin(INT_MAX),
|
||||||
@ -127,6 +128,7 @@ TileGenerator::TileGenerator():
|
|||||||
|
|
||||||
TileGenerator::~TileGenerator()
|
TileGenerator::~TileGenerator()
|
||||||
{
|
{
|
||||||
|
closeDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileGenerator::setBgColor(const std::string &bgColor)
|
void TileGenerator::setBgColor(const std::string &bgColor)
|
||||||
@ -246,6 +248,7 @@ void TileGenerator::generate(const std::string &input, const std::string &output
|
|||||||
loadBlocks();
|
loadBlocks();
|
||||||
createImage();
|
createImage();
|
||||||
renderMap();
|
renderMap();
|
||||||
|
closeDatabase();
|
||||||
if (m_drawScale) {
|
if (m_drawScale) {
|
||||||
renderScale();
|
renderScale();
|
||||||
}
|
}
|
||||||
@ -314,6 +317,12 @@ void TileGenerator::openDb(const std::string &input)
|
|||||||
throw std::runtime_error(((std::string) "Unknown map backend: ") + backend);
|
throw std::runtime_error(((std::string) "Unknown map backend: ") + backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileGenerator::closeDatabase()
|
||||||
|
{
|
||||||
|
delete m_db;
|
||||||
|
m_db = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void TileGenerator::loadBlocks()
|
void TileGenerator::loadBlocks()
|
||||||
{
|
{
|
||||||
std::vector<BlockPos> vec = m_db->getBlockPos();
|
std::vector<BlockPos> vec = m_db->getBlockPos();
|
||||||
|
@ -76,6 +76,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void parseColorsStream(std::istream &in);
|
void parseColorsStream(std::istream &in);
|
||||||
void openDb(const std::string &input);
|
void openDb(const std::string &input);
|
||||||
|
void closeDatabase();
|
||||||
void loadBlocks();
|
void loadBlocks();
|
||||||
void createImage();
|
void createImage();
|
||||||
void renderMap();
|
void renderMap();
|
||||||
|
@ -9,7 +9,7 @@ public:
|
|||||||
DBLevelDB(const std::string &mapdir);
|
DBLevelDB(const std::string &mapdir);
|
||||||
virtual std::vector<BlockPos> getBlockPos();
|
virtual std::vector<BlockPos> getBlockPos();
|
||||||
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos);
|
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos);
|
||||||
~DBLevelDB();
|
virtual ~DBLevelDB();
|
||||||
private:
|
private:
|
||||||
void loadPosCache();
|
void loadPosCache();
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ public:
|
|||||||
DBRedis(const std::string &mapdir);
|
DBRedis(const std::string &mapdir);
|
||||||
virtual std::vector<BlockPos> getBlockPos();
|
virtual std::vector<BlockPos> getBlockPos();
|
||||||
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos);
|
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos);
|
||||||
~DBRedis();
|
virtual ~DBRedis();
|
||||||
private:
|
private:
|
||||||
void loadPosCache();
|
void loadPosCache();
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ public:
|
|||||||
DBSQLite3(const std::string &mapdir);
|
DBSQLite3(const std::string &mapdir);
|
||||||
virtual std::vector<BlockPos> getBlockPos();
|
virtual std::vector<BlockPos> getBlockPos();
|
||||||
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos);
|
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos);
|
||||||
~DBSQLite3();
|
virtual ~DBSQLite3();
|
||||||
private:
|
private:
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
|
|
||||||
|
1
db.h
1
db.h
@ -55,6 +55,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
virtual std::vector<BlockPos> getBlockPos() = 0;
|
virtual std::vector<BlockPos> getBlockPos() = 0;
|
||||||
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos) = 0;
|
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos) = 0;
|
||||||
|
virtual ~DB() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user