Merge pull request #2024 from Diapolo/fix_qt_crash

Bitcoin-Qt: fix crash on Windows caused by CDBEnv::EnvShutdown()
This commit is contained in:
Wladimir J. van der Laan 2012-11-22 02:08:42 -08:00
commit b0e228a4b0
2 changed files with 6 additions and 2 deletions

View File

@ -38,11 +38,13 @@ void CDBEnv::EnvShutdown()
if (ret != 0) if (ret != 0)
printf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret); printf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret);
if (!fMockDb) if (!fMockDb)
DbEnv(0).remove(GetDataDir().string().c_str(), 0); DbEnv(0).remove(strPath.c_str(), 0);
} }
CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS) CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS)
{ {
fDbEnvInit = false;
fMockDb = false;
} }
CDBEnv::~CDBEnv() CDBEnv::~CDBEnv()
@ -63,6 +65,7 @@ bool CDBEnv::Open(const boost::filesystem::path& path)
if (fShutdown) if (fShutdown)
return false; return false;
strPath = path.string();
filesystem::path pathLogDir = path / "database"; filesystem::path pathLogDir = path / "database";
filesystem::create_directory(pathLogDir); filesystem::create_directory(pathLogDir);
filesystem::path pathErrorFile = path / "db.log"; filesystem::path pathErrorFile = path / "db.log";
@ -83,7 +86,7 @@ bool CDBEnv::Open(const boost::filesystem::path& path)
dbenv.set_flags(DB_AUTO_COMMIT, 1); dbenv.set_flags(DB_AUTO_COMMIT, 1);
dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1); dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1);
dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
int ret = dbenv.open(path.string().c_str(), int ret = dbenv.open(strPath.c_str(),
DB_CREATE | DB_CREATE |
DB_INIT_LOCK | DB_INIT_LOCK |
DB_INIT_LOG | DB_INIT_LOG |

View File

@ -33,6 +33,7 @@ class CDBEnv
private: private:
bool fDbEnvInit; bool fDbEnvInit;
bool fMockDb; bool fMockDb;
std::string strPath;
void EnvShutdown(); void EnvShutdown();