From d8f460200a2986e188cced9d97519e87797cccee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 10 Jul 2020 03:40:53 +0200 Subject: [PATCH] Use wxCoTaskMemPtr<> instead of manual ::CoTaskMemFree() No real changes, just use a smart pointer instead of manual memory management calls. --- src/msw/dirdlg.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/msw/dirdlg.cpp b/src/msw/dirdlg.cpp index 39080de388..3e8044d1d5 100644 --- a/src/msw/dirdlg.cpp +++ b/src/msw/dirdlg.cpp @@ -40,6 +40,7 @@ #include "wx/msw/private.h" #include "wx/msw/wrapshl.h" #include "wx/msw/private/comptr.h" +#include "wx/msw/private/cotaskmemptr.h" #include "wx/dynlib.h" #include @@ -483,8 +484,8 @@ bool GetPathsFromIFileOpenDialog(const wxCOMPtr& fileDialog, bo // helper function for wxDirDialog::ShowIFileOpenDialog() bool ConvertIShellItemToPath(const wxCOMPtr& item, wxString& path) { - LPOLESTR pathOLE = NULL; - const HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &pathOLE); + wxCoTaskMemPtr pOLEPath; + const HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &pOLEPath); if ( FAILED(hr) ) { @@ -492,8 +493,7 @@ bool ConvertIShellItemToPath(const wxCOMPtr& item, wxString& path) return false; } - path = pathOLE; - CoTaskMemFree(pathOLE); + path = pOLEPath; return true; }