diff --git a/src/app/crash/session.cpp b/src/app/crash/session.cpp index 3e2e9f70c..5c8b45728 100644 --- a/src/app/crash/session.cpp +++ b/src/app/crash/session.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2020 Igara Studio S.A. +// Copyright (C) 2019-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -333,18 +333,13 @@ Doc* Session::restoreBackupRawImages(Backup* backup, void Session::deleteBackup(Backup* backup) { - try { - auto it = std::find(m_backups.begin(), m_backups.end(), backup); - ASSERT(it != m_backups.end()); - if (it != m_backups.end()) - m_backups.erase(it); + auto it = std::find(m_backups.begin(), m_backups.end(), backup); + ASSERT(it != m_backups.end()); + if (it != m_backups.end()) + m_backups.erase(it); - if (base::is_directory(backup->dir())) - deleteDirectory(backup->dir()); - } - catch (const std::exception& ex) { - Console::showException(ex); - } + if (base::is_directory(backup->dir())) + deleteDirectory(backup->dir()); } void Session::loadPid() diff --git a/src/app/ui/data_recovery_view.cpp b/src/app/ui/data_recovery_view.cpp index 24d179ad4..3ce30db85 100644 --- a/src/app/ui/data_recovery_view.cpp +++ b/src/app/ui/data_recovery_view.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2020 Igara Studio S.A. +// Copyright (C) 2019-2021 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -13,6 +13,7 @@ #include "app/app.h" #include "app/app_menus.h" +#include "app/console.h" #include "app/crash/data_recovery.h" #include "app/crash/session.h" #include "app/doc.h" @@ -107,19 +108,31 @@ public: m_task = new TaskWidget( TaskWidget::kCannotCancel, - [this](base::task_token& t){ - // Warning: This is executed from a worker thread - m_session->deleteBackup(m_backup); - ui::execute_from_ui_thread( - [this]{ - onDeleteTaskWidget(); + [this](base::task_token& t) { + try { + // Warning: This is executed from a worker thread + m_session->deleteBackup(m_backup); - // We cannot use this->deferDelete() here because it looks - // like the m_task field can be still in use. - setVisible(false); + ui::execute_from_ui_thread( + [this]{ + onDeleteTaskWidget(); - updateView(); - }); + // We cannot use this->deferDelete() here because it looks + // like the m_task field can be still in use. + setVisible(false); + + updateView(); + }); + } + catch (const std::exception& ex) { + std::string err = ex.what(); + if (!err.empty()) { + ui::execute_from_ui_thread( + [err]{ + Console().printf("Error deleting file: %s", err.c_str()); + }); + } + } }); addChild(m_task); updateView(); @@ -473,6 +486,7 @@ void DataRecoveryView::onDelete() int(items.size()))) != 1) return; // Cancel + Console console; for (auto item : items) item->deleteBackup(); }