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
This commit is contained in:
@@ -103,6 +103,7 @@
|
|||||||
#include <shlobj.h> // for CLSID_ShellLink
|
#include <shlobj.h> // for CLSID_ShellLink
|
||||||
#include "wx/msw/missing.h"
|
#include "wx/msw/missing.h"
|
||||||
#include "wx/msw/ole/oleutils.h"
|
#include "wx/msw/ole/oleutils.h"
|
||||||
|
#include "wx/msw/private/comptr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
@@ -1655,7 +1656,7 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath,
|
|||||||
wxFileName::SplitPath(shortcutPath, & path, & file, & ext);
|
wxFileName::SplitPath(shortcutPath, & path, & file, & ext);
|
||||||
|
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
IShellLink* psl;
|
wxCOMPtr<IShellLink> psl;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
// Assume it's not a shortcut if it doesn't end with lnk
|
// 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))
|
if (SUCCEEDED(hres))
|
||||||
{
|
{
|
||||||
IPersistFile* ppf;
|
wxCOMPtr<IPersistFile> ppf;
|
||||||
hres = psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf);
|
hres = psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf);
|
||||||
if (SUCCEEDED(hres))
|
if (SUCCEEDED(hres))
|
||||||
{
|
{
|
||||||
@@ -1681,8 +1682,6 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath,
|
|||||||
MAX_PATH);
|
MAX_PATH);
|
||||||
|
|
||||||
hres = ppf->Load(wsz, 0);
|
hres = ppf->Load(wsz, 0);
|
||||||
ppf->Release();
|
|
||||||
|
|
||||||
if (SUCCEEDED(hres))
|
if (SUCCEEDED(hres))
|
||||||
{
|
{
|
||||||
wxChar buf[2048];
|
wxChar buf[2048];
|
||||||
@@ -1703,8 +1702,6 @@ bool wxFileName::GetShortcutTarget(const wxString& shortcutPath,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
psl->Release();
|
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user