diff --git a/src/app/crash/data_recovery.cpp b/src/app/crash/data_recovery.cpp index e12fbf1e7..0dba039f7 100644 --- a/src/app/crash/data_recovery.cpp +++ b/src/app/crash/data_recovery.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2023 Igara Studio S.A. +// Copyright (C) 2019-2025 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -139,6 +139,13 @@ DataRecovery::Sessions DataRecovery::sessions() return copy; } +bool DataRecovery::isRunningSession(const SessionPtr& session) const +{ + ASSERT(session); + ASSERT(m_inProgress); + return session->path() == m_inProgress->path(); +} + void DataRecovery::searchForSessions() { Sessions sessions; @@ -150,7 +157,7 @@ void DataRecovery::searchForSessions() RECO_TRACE("RECO: Session '%s' ", itempath.c_str()); SessionPtr session(new Session(&m_config, itempath)); - if (!session->isRunning()) { + if (!isRunningSession(session)) { if ((session->isEmpty()) || (!session->isCrashedSession() && session->isOldSession())) { RECO_TRACE("to be deleted (%s)\n", session->isEmpty() ? "is empty" : diff --git a/src/app/crash/data_recovery.h b/src/app/crash/data_recovery.h index 3b857f4a1..02c3efb2c 100644 --- a/src/app/crash/data_recovery.h +++ b/src/app/crash/data_recovery.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2021 Igara Studio S.A. +// Copyright (C) 2019-2025 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -45,6 +45,8 @@ public: // Returns a copy of the list of sessions that can be recovered. Sessions sessions(); + bool isRunningSession(const SessionPtr& session) const; + // Triggered in the UI-thread from the m_thread using an // ui::execute_from_ui_thread() when the list of sessions is ready // to be used. diff --git a/src/app/crash/session.cpp b/src/app/crash/session.cpp index 764485e5b..6427d251f 100644 --- a/src/app/crash/session.cpp +++ b/src/app/crash/session.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2024 Igara Studio S.A. +// Copyright (C) 2019-2025 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -19,12 +19,10 @@ #include "app/crash/write_document.h" #include "app/doc.h" #include "app/doc_access.h" -#include "app/file/file.h" #include "app/ui_context.h" #include "base/convert_to.h" #include "base/fs.h" #include "base/fstream_path.h" -#include "base/process.h" #include "base/split_string.h" #include "base/string.h" #include "base/thread.h" @@ -128,12 +126,6 @@ const Session::Backups& Session::backups() return m_backups; } -bool Session::isRunning() -{ - loadPid(); - return base::get_process_name(m_pid) == base::get_process_name(base::get_current_process_id()); -} - bool Session::isCrashedSession() { loadPid(); diff --git a/src/app/crash/session.h b/src/app/crash/session.h index d6cfcd747..ccf3e34ff 100644 --- a/src/app/crash/session.h +++ b/src/app/crash/session.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2022 Igara Studio S.A. +// Copyright (C) 2019-2025 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -47,9 +47,9 @@ public: std::string name() const; std::string version(); + std::string& path() { return m_path; } const Backups& backups(); - bool isRunning(); bool isCrashedSession(); bool isOldSession(); bool isEmpty();