Close database when done
This prevents messages 'Connection reset by peer' in the postgresql log file. It might have benefits for other databases as well ?
This commit is contained in:
parent
ba9166fd79
commit
dbec678f6b
@ -202,6 +202,7 @@ TileGenerator::TileGenerator():
|
|||||||
|
|
||||||
TileGenerator::~TileGenerator()
|
TileGenerator::~TileGenerator()
|
||||||
{
|
{
|
||||||
|
closeDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileGenerator::setSilenceSuggestion(unsigned flags)
|
void TileGenerator::setSilenceSuggestion(unsigned flags)
|
||||||
@ -557,6 +558,7 @@ void TileGenerator::generate(const std::string &input, const std::string &output
|
|||||||
if (!m_drawObjects.empty()) {
|
if (!m_drawObjects.empty()) {
|
||||||
renderDrawObjects();
|
renderDrawObjects();
|
||||||
}
|
}
|
||||||
|
closeDb();
|
||||||
if (progressIndicator)
|
if (progressIndicator)
|
||||||
cout << "Writing image...\r" << std::flush;
|
cout << "Writing image...\r" << std::flush;
|
||||||
writeImage(output);
|
writeImage(output);
|
||||||
@ -859,6 +861,14 @@ void TileGenerator::openDb(const std::string &input)
|
|||||||
throw std::runtime_error(((std::string) "World uses backend '") + m_backend + ", which was not enabled at compile-time.");
|
throw std::runtime_error(((std::string) "World uses backend '") + m_backend + ", which was not enabled at compile-time.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileGenerator::closeDb()
|
||||||
|
{
|
||||||
|
if (m_db) {
|
||||||
|
delete m_db;
|
||||||
|
m_db = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TileGenerator::loadBlocks()
|
void TileGenerator::loadBlocks()
|
||||||
{
|
{
|
||||||
int mapXMin, mapXMax;
|
int mapXMin, mapXMax;
|
||||||
|
@ -162,6 +162,7 @@ private:
|
|||||||
std::string getWorldDatabaseBackend(const std::string &input);
|
std::string getWorldDatabaseBackend(const std::string &input);
|
||||||
int getMapChunkSize(const std::string &input);
|
int getMapChunkSize(const std::string &input);
|
||||||
void openDb(const std::string &input);
|
void openDb(const std::string &input);
|
||||||
|
void closeDb();
|
||||||
void sanitizeParameters(void);
|
void sanitizeParameters(void);
|
||||||
void loadBlocks();
|
void loadBlocks();
|
||||||
void createImage();
|
void createImage();
|
||||||
|
1
db.h
1
db.h
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
class DB {
|
class DB {
|
||||||
public:
|
public:
|
||||||
|
virtual ~DB() {}
|
||||||
typedef std::pair<BlockPos, ustring> Block;
|
typedef std::pair<BlockPos, ustring> Block;
|
||||||
typedef std::vector<BlockPos> BlockPosList;
|
typedef std::vector<BlockPos> BlockPosList;
|
||||||
virtual const BlockPosList &getBlockPosList()=0;
|
virtual const BlockPosList &getBlockPosList()=0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user