fix bug that folderbox returns an emtpy path

This commit is contained in:
Jinhao 2018-06-26 08:06:43 +08:00
parent a781a8790f
commit 3075eccacf

View File

@ -1224,7 +1224,7 @@ namespace nana
std::optional<folderbox::path_type> folderbox::show() const std::optional<folderbox::path_type> folderbox::show() const
{ {
#ifdef NANA_WINDOWS #ifdef NANA_WINDOWS
path_type target; std::optional<folderbox::path_type> target;
CoInitialize(NULL); CoInitialize(NULL);
IFileDialog *fd(nullptr); IFileDialog *fd(nullptr);
@ -1246,7 +1246,7 @@ namespace nana
hr = si->GetDisplayName(SIGDN_FILESYSPATH, &pwstr); hr = si->GetDisplayName(SIGDN_FILESYSPATH, &pwstr);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
target = pwstr; target = path_type{ pwstr };
// use the c-string pointed to by pwstr here // use the c-string pointed to by pwstr here
CoTaskMemFree(pwstr); CoTaskMemFree(pwstr);
} }