mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 06:32:42 +00:00
Fix issue 366: Crash (uncaught exception) on closing application
This commit is contained in:
parent
30e26e2a3a
commit
45f0166508
@ -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;
|
||||
|
@ -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; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user