Fix issue 366: Crash (uncaught exception) on closing application

This commit is contained in:
David Capello 2014-03-08 21:15:48 -03:00
parent 30e26e2a3a
commit 45f0166508
2 changed files with 16 additions and 4 deletions

View File

@ -37,14 +37,25 @@ TempDir::TempDir(const string& appName)
TempDir::~TempDir()
{
if (!m_path.empty())
remove_directory(m_path);
remove();
}
void TempDir::remove()
{
if (!m_path.empty()) {
try {
remove_directory(m_path);
}
catch (const std::exception&) {
// Ignore exceptions if the directory cannot be removed.
}
m_path.clear();
}
}
void TempDir::attach(const string& path)
{
if (!m_path.empty())
remove_directory(m_path);
remove();
ASSERT(directory_exists(path));
m_path = path;

View File

@ -17,6 +17,7 @@ namespace base {
TempDir(const string& appName);
~TempDir();
void remove();
void attach(const string& path);
const string& path() const { return m_path; }