From a704ab9cc0a03e943593c3b21e206aaac87bec03 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Aug 2014 23:22:09 +0000 Subject: [PATCH] Use wxCOMPtr<> in wxFileName instead of manual Release() calls. Make the code shorter and safer. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77510 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/filename.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 9a50f81634..4dd52de2e0 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -103,6 +103,7 @@ #include // for CLSID_ShellLink #include "wx/msw/missing.h" #include "wx/msw/ole/oleutils.h" + #include "wx/msw/private/comptr.h" #endif #if defined(__WXMAC__) @@ -1655,7 +1656,7 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath, wxFileName::SplitPath(shortcutPath, & path, & file, & ext); HRESULT hres; - IShellLink* psl; + wxCOMPtr psl; bool success = false; // Assume it's not a shortcut if it doesn't end with lnk @@ -1671,7 +1672,7 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath, if (SUCCEEDED(hres)) { - IPersistFile* ppf; + wxCOMPtr ppf; hres = psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf); if (SUCCEEDED(hres)) { @@ -1681,8 +1682,6 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath, MAX_PATH); hres = ppf->Load(wsz, 0); - ppf->Release(); - if (SUCCEEDED(hres)) { wxChar buf[2048]; @@ -1703,8 +1702,6 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath, } } } - - psl->Release(); } return success; }