mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
FileBasedDocument: Fix use-after-move bug
This commit is contained in:
parent
630afbda54
commit
024a0b4a20
1 changed files with 16 additions and 22 deletions
|
|
@ -440,15 +440,13 @@ private:
|
|||
int askToSaveChanges (SafeParentPointer parent,
|
||||
std::function<void (SafeParentPointer, int)> callback)
|
||||
{
|
||||
auto wrappedCallback = [parent, callback = std::move (callback)] (int alertResult)
|
||||
{
|
||||
if (parent != nullptr)
|
||||
callback (parent, alertResult);
|
||||
};
|
||||
|
||||
auto modalCallback = callback == nullptr
|
||||
? nullptr
|
||||
: ModalCallbackFunction::create (std::move (wrappedCallback));
|
||||
auto* modalCallback = callback == nullptr
|
||||
? nullptr
|
||||
: ModalCallbackFunction::create ([parent, callback = std::move (callback)] (int alertResult)
|
||||
{
|
||||
if (parent != nullptr)
|
||||
callback (parent, alertResult);
|
||||
});
|
||||
|
||||
return AlertWindow::showYesNoCancelBox (AlertWindow::QuestionIcon,
|
||||
TRANS ("Closing document..."),
|
||||
|
|
@ -458,7 +456,7 @@ private:
|
|||
TRANS ("Discard changes"),
|
||||
TRANS ("Cancel"),
|
||||
nullptr,
|
||||
std::move (modalCallback));
|
||||
modalCallback);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -676,17 +674,13 @@ private:
|
|||
if (parent == nullptr)
|
||||
return false;
|
||||
|
||||
auto wrappedCallback = [parent, callback = std::move (callback)] (int r)
|
||||
{
|
||||
if (parent == nullptr)
|
||||
return;
|
||||
|
||||
callback (parent, r == 1);
|
||||
};
|
||||
|
||||
auto modalCallback = callback == nullptr
|
||||
? nullptr
|
||||
: ModalCallbackFunction::create (std::move (wrappedCallback));
|
||||
auto* modalCallback = callback == nullptr
|
||||
? nullptr
|
||||
: ModalCallbackFunction::create ([parent, callback = std::move (callback)] (int r)
|
||||
{
|
||||
if (parent != nullptr)
|
||||
callback (parent, r == 1);
|
||||
});
|
||||
|
||||
return AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
|
||||
TRANS ("File already exists"),
|
||||
|
|
@ -697,7 +691,7 @@ private:
|
|||
TRANS ("Overwrite"),
|
||||
TRANS ("Cancel"),
|
||||
nullptr,
|
||||
std::move (modalCallback));
|
||||
modalCallback);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue