savedata dialog: fix SaveDialogUi move semantics

fix possible dangling points
This commit is contained in:
Vinicius Rangel 2025-04-27 12:36:28 -03:00
parent 0ba9ea6a3b
commit 3607393eb2
No known key found for this signature in database
GPG Key ID: A5B154D904B761D9
2 changed files with 9 additions and 5 deletions

View File

@ -345,12 +345,15 @@ SaveDialogUi::SaveDialogUi(SaveDialogUi&& other) noexcept
} }
} }
SaveDialogUi& SaveDialogUi::operator=(SaveDialogUi other) { SaveDialogUi& SaveDialogUi::operator=(SaveDialogUi&& other) noexcept {
std::scoped_lock lock(draw_mutex, other.draw_mutex); std::scoped_lock lock(draw_mutex, other.draw_mutex);
using std::swap; using std::swap;
swap(state, other.state); state = other.state;
swap(status, other.status); other.state = nullptr;
swap(result, other.result); status = other.status;
other.status = nullptr;
result = other.result;
other.result = nullptr;
if (status && *status == Status::RUNNING) { if (status && *status == Status::RUNNING) {
first_render = true; first_render = true;
AddLayer(this); AddLayer(this);

View File

@ -300,7 +300,8 @@ public:
~SaveDialogUi() override; ~SaveDialogUi() override;
SaveDialogUi(const SaveDialogUi& other) = delete; SaveDialogUi(const SaveDialogUi& other) = delete;
SaveDialogUi(SaveDialogUi&& other) noexcept; SaveDialogUi(SaveDialogUi&& other) noexcept;
SaveDialogUi& operator=(SaveDialogUi other); SaveDialogUi& operator=(SaveDialogUi& other) = delete;
SaveDialogUi& operator=(SaveDialogUi&& other) noexcept;
void Finish(ButtonId buttonId, CommonDialog::Result r = CommonDialog::Result::OK); void Finish(ButtonId buttonId, CommonDialog::Result r = CommonDialog::Result::OK);