mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-08 04:20:09 +00:00
FileChooser: Launch chooser asynchronously
When FileChooser instances were created, launched, and hidden all inside the same event callback on macOS 12.0.1, the chooser dialog sometimes remained open. This could cause problems including crashes, as closing the dialog would attempt to call a completion handler block referencing an already-deleted FileChooser::Native instance. Opening the chooser panel later on the message thread seems to resolve the issue.
This commit is contained in:
parent
8458ac0186
commit
da46ee6c7a
1 changed files with 12 additions and 12 deletions
|
|
@ -82,8 +82,9 @@ public:
|
|||
filters.trim();
|
||||
filters.removeEmptyStrings();
|
||||
|
||||
NSString* nsTitle = juceStringToNS (owner.title);
|
||||
auto* nsTitle = juceStringToNS (owner.title);
|
||||
[panel setTitle: nsTitle];
|
||||
[panel setReleasedWhenClosed: YES];
|
||||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
[panel setAllowedFileTypes: createAllowedTypesArray (filters)];
|
||||
|
|
@ -153,22 +154,14 @@ public:
|
|||
if (nsViewPreview != nil)
|
||||
{
|
||||
[panel setAccessoryView: nil];
|
||||
|
||||
[nsViewPreview release];
|
||||
|
||||
nsViewPreview = nil;
|
||||
preview = nullptr;
|
||||
}
|
||||
|
||||
[panel close];
|
||||
[panel release];
|
||||
}
|
||||
|
||||
if (delegate != nil)
|
||||
{
|
||||
[delegate release];
|
||||
delegate = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void launch() override
|
||||
|
|
@ -179,10 +172,17 @@ public:
|
|||
addToDesktop (0);
|
||||
|
||||
enterModalState (true);
|
||||
[panel beginWithCompletionHandler:CreateObjCBlock (this, &Native::finished)];
|
||||
|
||||
if (preview != nullptr)
|
||||
preview->toFront (true);
|
||||
MessageManager::callAsync ([ref = SafePointer<Native> (this)]
|
||||
{
|
||||
if (ref == nullptr)
|
||||
return;
|
||||
|
||||
[ref->panel beginWithCompletionHandler: CreateObjCBlock (ref.getComponent(), &Native::finished)];
|
||||
|
||||
if (ref->preview != nullptr)
|
||||
ref->preview->toFront (true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue