Commit 17339f4f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

shell32: Cleanup IShellItem creation calls.

parent e9d010ef
...@@ -548,7 +548,6 @@ HRESULT WINAPI IShellItem_Constructor(IUnknown *pUnkOuter, REFIID riid, void **p ...@@ -548,7 +548,6 @@ HRESULT WINAPI IShellItem_Constructor(IUnknown *pUnkOuter, REFIID riid, void **p
HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi) IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
{ {
ShellItem *This;
LPITEMIDLIST new_pidl; LPITEMIDLIST new_pidl;
HRESULT ret; HRESULT ret;
...@@ -597,16 +596,9 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, ...@@ -597,16 +596,9 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
ret = IShellItem_Constructor(NULL, &IID_IShellItem, (void**)&This); ret = SHCreateItemFromIDList(new_pidl, &IID_IShellItem, (void**)ppsi);
if (This)
{
*ppsi = (IShellItem*)&This->IShellItem2_iface;
This->pidl = new_pidl;
}
else
{
ILFree(new_pidl); ILFree(new_pidl);
}
return ret; return ret;
} }
...@@ -621,37 +613,34 @@ HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath, ...@@ -621,37 +613,34 @@ HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath,
ret = SHParseDisplayName(pszPath, pbc, &pidl, 0, NULL); ret = SHParseDisplayName(pszPath, pbc, &pidl, 0, NULL);
if(SUCCEEDED(ret)) if(SUCCEEDED(ret))
{ {
ShellItem *This; ret = SHCreateItemFromIDList(pidl, riid, ppv);
ret = IShellItem_Constructor(NULL, riid, (void**)&This);
if(SUCCEEDED(ret))
{
This->pidl = pidl;
*ppv = (void*)This;
}
else
{
ILFree(pidl); ILFree(pidl);
} }
}
return ret; return ret;
} }
HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv) HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv)
{ {
ShellItem *psiimpl; IPersistIDList *persist;
HRESULT ret; HRESULT ret;
if(!pidl) if(!pidl)
return E_INVALIDARG; return E_INVALIDARG;
ret = IShellItem_Constructor(NULL, riid, ppv); *ppv = NULL;
if(SUCCEEDED(ret)) ret = IShellItem_Constructor(NULL, &IID_IPersistIDList, (void**)&persist);
if(FAILED(ret))
return ret;
ret = IPersistIDList_SetIDList(persist, pidl);
if(FAILED(ret))
{ {
psiimpl = (ShellItem*)*ppv; IPersistIDList_Release(persist);
psiimpl->pidl = ILClone(pidl); return ret;
} }
ret = IPersistIDList_QueryInterface(persist, riid, ppv);
IPersistIDList_Release(persist);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment