Use wxCoTaskMemPtr<> instead of manual ::CoTaskMemFree()

No real changes, just use a smart pointer instead of manual memory
management calls.
This commit is contained in:
Vadim Zeitlin
2020-07-10 03:40:53 +02:00
parent 83aa1a19a5
commit d8f460200a

View File

@@ -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 <initguid.h>
@@ -483,8 +484,8 @@ bool GetPathsFromIFileOpenDialog(const wxCOMPtr<IFileOpenDialog>& fileDialog, bo
// helper function for wxDirDialog::ShowIFileOpenDialog()
bool ConvertIShellItemToPath(const wxCOMPtr<IShellItem>& item, wxString& path)
{
LPOLESTR pathOLE = NULL;
const HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &pathOLE);
wxCoTaskMemPtr<WCHAR> pOLEPath;
const HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &pOLEPath);
if ( FAILED(hr) )
{
@@ -492,8 +493,7 @@ bool ConvertIShellItemToPath(const wxCOMPtr<IShellItem>& item, wxString& path)
return false;
}
path = pathOLE;
CoTaskMemFree(pathOLE);
path = pOLEPath;
return true;
}