atl: Simplify error handling in AtlAxAttachControl().
This commit is contained in:
parent
68f2b878d2
commit
2b390f01ed
|
@ -949,12 +949,15 @@ static HRESULT IOCS_Init( IOCS *This )
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Create new instance of Atl host component and attach it to window *
|
* Create new instance of Atl host component and attach it to window *
|
||||||
*/
|
*/
|
||||||
static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IOCS **ppSite )
|
static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IUnknown **container )
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IOCS *This;
|
IOCS *This;
|
||||||
|
|
||||||
*ppSite = NULL;
|
if (!container)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
*container = NULL;
|
||||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(IOCS));
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(IOCS));
|
||||||
|
|
||||||
if (!This)
|
if (!This)
|
||||||
|
@ -975,7 +978,7 @@ static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IOCS **ppSite )
|
||||||
if ( SUCCEEDED( hr ) )
|
if ( SUCCEEDED( hr ) )
|
||||||
hr = IOCS_Init( This );
|
hr = IOCS_Init( This );
|
||||||
if ( SUCCEEDED( hr ) )
|
if ( SUCCEEDED( hr ) )
|
||||||
*ppSite = This;
|
*container = (IUnknown*)&This->IOleClientSite_iface;
|
||||||
else
|
else
|
||||||
IOCS_Release( This );
|
IOCS_Release( This );
|
||||||
|
|
||||||
|
@ -1102,26 +1105,17 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* AtlAxAttachControl [atl100.@]
|
* AtlAxAttachControl [atl100.@]
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI AtlAxAttachControl(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer)
|
HRESULT WINAPI AtlAxAttachControl(IUnknown *control, HWND hWnd, IUnknown **container)
|
||||||
{
|
{
|
||||||
IOCS *pUnkContainer;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE( "%p %p %p\n", pControl, hWnd, ppUnkContainer );
|
TRACE("(%p %p %p)\n", control, hWnd, container);
|
||||||
|
|
||||||
if (!pControl)
|
if (!control)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
hr = IOCS_Create( hWnd, pControl, &pUnkContainer );
|
hr = IOCS_Create( hWnd, control, container );
|
||||||
if ( SUCCEEDED( hr ) && ppUnkContainer)
|
return hWnd ? hr : S_FALSE;
|
||||||
{
|
|
||||||
*ppUnkContainer = (IUnknown*) pUnkContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!hWnd)
|
|
||||||
return S_FALSE;
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
|
@ -97,14 +97,10 @@ static void test_AtlAxAttachControl(void)
|
||||||
hr = pAtlAxAttachControl(pObj, NULL, NULL);
|
hr = pAtlAxAttachControl(pObj, NULL, NULL);
|
||||||
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
|
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
|
||||||
|
|
||||||
pContainer = (IUnknown *)0xdeadbeef;
|
pContainer = NULL;
|
||||||
hr = pAtlAxAttachControl(pObj, NULL, &pContainer);
|
hr = pAtlAxAttachControl(pObj, NULL, &pContainer);
|
||||||
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
|
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
|
||||||
ok(pContainer != (IUnknown *)0xdeadbeef &&
|
ok(pContainer != NULL, "got %p\n", pContainer);
|
||||||
pContainer != NULL,
|
|
||||||
"Expected the output container pointer to be initialized to non-NULL, got %p\n", pContainer);
|
|
||||||
|
|
||||||
if (pContainer != (IUnknown *)0xdeadbeef && pContainer != NULL)
|
|
||||||
IUnknown_Release(pContainer);
|
IUnknown_Release(pContainer);
|
||||||
|
|
||||||
hr = pAtlAxAttachControl(pObj, hwnd, NULL);
|
hr = pAtlAxAttachControl(pObj, hwnd, NULL);
|
||||||
|
|
Loading…
Reference in New Issue