mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-22 01:34:21 +00:00
FileChooser: Avoid crash when destroying an open non-native filechooser
This commit is contained in:
parent
0f06f45098
commit
793f1bf2ee
1 changed files with 11 additions and 2 deletions
|
|
@ -27,7 +27,8 @@ namespace juce
|
|||
{
|
||||
|
||||
//==============================================================================
|
||||
class FileChooser::NonNative : public FileChooser::Pimpl
|
||||
class FileChooser::NonNative : public std::enable_shared_from_this<NonNative>,
|
||||
public FileChooser::Pimpl
|
||||
{
|
||||
public:
|
||||
NonNative (FileChooser& fileChooser, int flags, FilePreviewComponent* preview)
|
||||
|
|
@ -50,7 +51,15 @@ public:
|
|||
void launch() override
|
||||
{
|
||||
dialogBox.centreWithDefaultSize (nullptr);
|
||||
dialogBox.enterModalState (true, ModalCallbackFunction::create ([this] (int r) { modalStateFinished (r); }), true);
|
||||
|
||||
const std::weak_ptr<NonNative> ref (shared_from_this());
|
||||
auto* callback = ModalCallbackFunction::create ([ref] (int r)
|
||||
{
|
||||
if (auto locked = ref.lock())
|
||||
locked->modalStateFinished (r);
|
||||
});
|
||||
|
||||
dialogBox.enterModalState (true, callback, true);
|
||||
}
|
||||
|
||||
void runModally() override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue