diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp index 654be39835..ac79377759 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp @@ -184,7 +184,7 @@ void FileChooser::launchAsync (int flags, std::function FileChooser::createPimpl (int flags, FilePreviewComponent* previewComp) +std::shared_ptr FileChooser::createPimpl (int flags, FilePreviewComponent* previewComp) { results.clear(); diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooser.h b/modules/juce_gui_basics/filebrowser/juce_FileChooser.h index c2b25f85aa..df6197b510 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooser.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooser.h @@ -328,8 +328,8 @@ private: std::shared_ptr pimpl; //============================================================================== - std::unique_ptr createPimpl (int, FilePreviewComponent*); - static std::unique_ptr showPlatformDialog (FileChooser&, int, FilePreviewComponent*); + std::shared_ptr createPimpl (int, FilePreviewComponent*); + static std::shared_ptr showPlatformDialog (FileChooser&, int, FilePreviewComponent*); class NonNative; friend class NonNative; diff --git a/modules/juce_gui_basics/native/juce_android_FileChooser.cpp b/modules/juce_gui_basics/native/juce_android_FileChooser.cpp index 8d26cac2c0..fea21a2e2c 100644 --- a/modules/juce_gui_basics/native/juce_android_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_android_FileChooser.cpp @@ -219,11 +219,11 @@ private: FileChooser::Native* FileChooser::Native::currentFileChooser = nullptr; -std::unique_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, +std::shared_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, FilePreviewComponent*) { if (FileChooser::Native::currentFileChooser == nullptr) - return std::make_unique (owner, flags); + return std::make_shared (owner, flags); // there can only be one file chooser on Android at a once jassertfalse; diff --git a/modules/juce_gui_basics/native/juce_ios_FileChooser.mm b/modules/juce_gui_basics/native/juce_ios_FileChooser.mm index 7a45fb90ab..d61b73f0be 100644 --- a/modules/juce_gui_basics/native/juce_ios_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_ios_FileChooser.mm @@ -379,10 +379,10 @@ bool FileChooser::isPlatformDialogAvailable() #endif } -std::unique_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, +std::shared_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, FilePreviewComponent*) { - return std::make_unique (owner, flags); + return std::make_shared (owner, flags); } #if JUCE_DEPRECATION_IGNORED diff --git a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp index 6ead1dfe76..746686bf75 100644 --- a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp @@ -256,9 +256,9 @@ bool FileChooser::isPlatformDialogAvailable() #endif } -std::unique_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, FilePreviewComponent*) +std::shared_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, FilePreviewComponent*) { - return std::make_unique (owner, flags); + return std::make_shared (owner, flags); } } // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index 6b980e335d..61febe1b1d 100644 --- a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -377,10 +377,10 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Native) }; -std::unique_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, +std::shared_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, FilePreviewComponent* preview) { - return std::make_unique (owner, flags, preview); + return std::make_shared (owner, flags, preview); } bool FileChooser::isPlatformDialogAvailable() diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index 26bfdc51fc..b16b5b9248 100755 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -82,6 +82,8 @@ public: // the thread should not be running nativeDialogRef.set (nullptr); + weakThis = shared_from_this(); + if (async) { jassert (! isThreadRunning()); @@ -140,6 +142,7 @@ private: //============================================================================== const Component::SafePointer owner; + std::weak_ptr weakThis; String title, filtersString; std::unique_ptr customComponent; String initialPath, returnedString; @@ -481,11 +484,11 @@ private: auto resultsCopy = openDialog (true); auto safeOwner = owner; - std::weak_ptr weakThis = shared_from_this(); + auto weakThisCopy = weakThis; - MessageManager::callAsync ([resultsCopy, safeOwner, weakThis] + MessageManager::callAsync ([resultsCopy, safeOwner, weakThisCopy] { - if (auto locked = weakThis.lock()) + if (auto locked = weakThisCopy.lock()) locked->results = resultsCopy; if (safeOwner != nullptr) @@ -812,10 +815,10 @@ bool FileChooser::isPlatformDialogAvailable() #endif } -std::unique_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, +std::shared_ptr FileChooser::showPlatformDialog (FileChooser& owner, int flags, FilePreviewComponent* preview) { - return std::make_unique (owner, flags, preview); + return std::make_shared (owner, flags, preview); } } // namespace juce