mirror of https://github.com/aseprite/aseprite.git
Fix ASSERT deleting a backup session on start when there is no UI
This can happen if the session folder cannto be deleted e.g. when the folder is not empty (for example if we've copied/created a file in the session folder manually).
This commit is contained in:
parent
ffbe4863ca
commit
2be11cf2f5
|
|
@ -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,7 +333,6 @@ 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())
|
||||
|
|
@ -342,10 +341,6 @@ void Session::deleteBackup(Backup* backup)
|
|||
if (base::is_directory(backup->dir()))
|
||||
deleteDirectory(backup->dir());
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
Console::showException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
void Session::loadPid()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -108,8 +109,10 @@ public:
|
|||
m_task = new TaskWidget(
|
||||
TaskWidget::kCannotCancel,
|
||||
[this](base::task_token& t) {
|
||||
try {
|
||||
// Warning: This is executed from a worker thread
|
||||
m_session->deleteBackup(m_backup);
|
||||
|
||||
ui::execute_from_ui_thread(
|
||||
[this]{
|
||||
onDeleteTaskWidget();
|
||||
|
|
@ -120,6 +123,16 @@ public:
|
|||
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue