FullscreenUI: Fix call of moved-from function

This commit is contained in:
Stenzek 2025-04-09 22:11:48 +10:00
parent 8186e615ab
commit 8e5531eaa2
No known key found for this signature in database

View File

@ -2723,8 +2723,8 @@ void ImGuiFullscreen::FileSelectorDialog::Draw()
{ {
if (selected->is_file) if (selected->is_file)
{ {
std::string path = std::move(selected->full_path); std::string path = std::exchange(selected->full_path, std::string());
const FileSelectorCallback callback = std::move(m_callback); const FileSelectorCallback callback = std::exchange(m_callback, FileSelectorCallback());
StartClose(); StartClose();
callback(std::move(path)); callback(std::move(path));
} }
@ -2735,8 +2735,8 @@ void ImGuiFullscreen::FileSelectorDialog::Draw()
} }
else if (directory_selected) else if (directory_selected)
{ {
std::string path = std::move(m_current_directory); std::string path = std::exchange(m_current_directory, std::string());
const FileSelectorCallback callback = std::move(m_callback); const FileSelectorCallback callback = std::exchange(m_callback, FileSelectorCallback());
StartClose(); StartClose();
callback(std::move(path)); callback(std::move(path));
} }
@ -2888,10 +2888,10 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
// because the callback may open another dialog, and we don't want to close that one. // because the callback may open another dialog, and we don't want to close that one.
if (!m_checkable) if (!m_checkable)
{ {
auto option = std::move(m_options[choice]); const ChoiceDialogOptions options = std::exchange(m_options, ChoiceDialogOptions());
const ChoiceDialogCallback callback = std::move(m_callback); const ChoiceDialogCallback callback = std::exchange(m_callback, ChoiceDialogCallback());
StartClose(); StartClose();
callback(choice, option.first, option.second); callback(choice, options[choice].first, options[choice].second);
} }
else else
{ {
@ -2993,8 +2993,8 @@ void ImGuiFullscreen::InputStringDialog::Draw()
if (MenuButtonWithoutSummary(m_ok_text.c_str(), ok_enabled) && ok_enabled) if (MenuButtonWithoutSummary(m_ok_text.c_str(), ok_enabled) && ok_enabled)
{ {
// have to move out in case they open another dialog in the callback // have to move out in case they open another dialog in the callback
InputStringDialogCallback cb = std::move(m_callback); const InputStringDialogCallback cb = std::exchange(m_callback, InputStringDialogCallback());
std::string text = std::move(m_text); std::string text = std::exchange(m_text, std::string());
StartClose(); StartClose();
cb(std::move(text)); cb(std::move(text));
} }
@ -3075,7 +3075,7 @@ void ImGuiFullscreen::MessageDialog::Draw()
{ {
// have to move out in case they open another dialog in the callback // have to move out in case they open another dialog in the callback
StartClose(); StartClose();
InvokeCallback(std::move(m_callback), result); InvokeCallback(std::exchange(m_callback, CallbackVariant()), result);
} }
} }