progress box should use stop source for requesting exit

This commit is contained in:
ITotalJustice
2025-01-14 15:54:34 +00:00
parent 977331c3b2
commit e2022eac4c
2 changed files with 3 additions and 11 deletions

View File

@@ -57,7 +57,6 @@ private:
std::string m_transfer{}; std::string m_transfer{};
s64 m_size{}; s64 m_size{};
s64 m_offset{}; s64 m_offset{};
bool m_exit_requested{};
}; };
// this is a helper function that does many things. // this is a helper function that does many things.

View File

@@ -52,9 +52,7 @@ ProgressBox::ProgressBox(const std::string& title, ProgressBoxCallback callback,
} }
ProgressBox::~ProgressBox() { ProgressBox::~ProgressBox() {
mutexLock(&m_mutex); m_stop_source.request_stop();
m_exit_requested = true;
mutexUnlock(&m_mutex);
if (R_FAILED(threadWaitForExit(&m_thread))) { if (R_FAILED(threadWaitForExit(&m_thread))) {
log_write("failed to join thread\n"); log_write("failed to join thread\n");
@@ -125,16 +123,11 @@ auto ProgressBox::UpdateTransfer(s64 offset, s64 size) -> ProgressBox& {
} }
void ProgressBox::RequestExit() { void ProgressBox::RequestExit() {
mutexLock(&m_mutex); m_stop_source.request_stop();
m_exit_requested = true;
mutexUnlock(&m_mutex);
} }
auto ProgressBox::ShouldExit() -> bool { auto ProgressBox::ShouldExit() -> bool {
mutexLock(&m_mutex); return m_stop_source.stop_requested();
const auto exit_requested = m_exit_requested;
mutexUnlock(&m_mutex);
return exit_requested;
} }
auto ProgressBox::CopyFile(const fs::FsPath& src_path, const fs::FsPath& dst_path) -> Result { auto ProgressBox::CopyFile(const fs::FsPath& src_path, const fs::FsPath& dst_path) -> Result {