1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

FileChooser: Hide chooser when it leaves scope on Windows

This commit is contained in:
reuk 2021-02-26 23:42:47 +00:00
parent e813531d9b
commit 45409bb4e6
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
9 changed files with 105 additions and 95 deletions

View file

@ -158,7 +158,7 @@ bool FileChooser::showDialog (const int flags, FilePreviewComponent* const previ
{
FocusRestorer focusRestorer;
pimpl.reset (createPimpl (flags, previewComp));
pimpl = createPimpl (flags, previewComp);
pimpl->runModally();
// ensure that the finished function was invoked
@ -179,12 +179,12 @@ void FileChooser::launchAsync (int flags, std::function<void (const FileChooser&
asyncCallback = std::move (callback);
pimpl.reset (createPimpl (flags, previewComp));
pimpl = createPimpl (flags, previewComp);
pimpl->launch();
}
FileChooser::Pimpl* FileChooser::createPimpl (int flags, FilePreviewComponent* previewComp)
std::unique_ptr<FileChooser::Pimpl> FileChooser::createPimpl (int flags, FilePreviewComponent* previewComp)
{
results.clear();
@ -214,10 +214,8 @@ FileChooser::Pimpl* FileChooser::createPimpl (int flags, FilePreviewComponent* p
{
return showPlatformDialog (*this, flags, previewComp);
}
else
{
return new NonNative (*this, flags, previewComp);
}
return std::make_unique<NonNative> (*this, flags, previewComp);
}
Array<File> FileChooser::getResults() const noexcept

View file

@ -325,12 +325,11 @@ private:
virtual void runModally() = 0;
};
std::unique_ptr<Pimpl> pimpl;
std::shared_ptr<Pimpl> pimpl;
//==============================================================================
Pimpl* createPimpl (int, FilePreviewComponent*);
static Pimpl* showPlatformDialog (FileChooser&, int,
FilePreviewComponent*);
std::unique_ptr<Pimpl> createPimpl (int, FilePreviewComponent*);
static std::unique_ptr<Pimpl> showPlatformDialog (FileChooser&, int, FilePreviewComponent*);
class NonNative;
friend class NonNative;