Open judicaelclair opened 2 years ago
Good catch! I did not think people would use pfd::internal::dialog
directly. Can you please explain what use you have for a std::unique_ptr<pfd::internal::dialog>
instead of a more explicit type?
I am asking because I am pondering an API change that switches to factories instead of constructors (see the feature/shared-ptr
branch), where e.g. pfd::open_file::create()
returns a std::shared_ptr<open_file>
. It will break your usage unless I take additional steps to allow conversions.
I have a thin wrapper to your library that manages callbacks and only allows at most a single dialog to be open at any time. This wrapper has a handle to pfd::internal::dialog so that you can kill an existing dialog by calling pfd::internal::dialog->kill().
Since you don't appear to be changing the inheritance hierarchy, I could easily adapt my wrapper by changing two lines:
std::unique_ptr<pfd::internal::dialog> dialog_;
dialog_ = std::make_unique<T>(std::forward<Args>(args)...);
to
std::shared_ptr<pfd::internal::dialog> dialog_;
dialog_ = T::create(std::forward<Args>(args)...);
However, I wonder why you want to use factories seeing as you're merely returning the shared pointer and not using it internally?
Fixes bug detected by gcc's address sanitizer: