Fixes 132705. nsComponentManagerUtils error handling is incorrect. fix by dbaron, r=dougt, sr=rpotts, a=asa@mozilla.org

This commit is contained in:
dougt%netscape.com 2002-04-04 21:35:32 +00:00
Родитель b607ddcbb0
Коммит 940379bb25
1 изменённых файлов: 14 добавлений и 16 удалений

Просмотреть файл

@ -50,13 +50,12 @@ nsresult
nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
{ {
nsCOMPtr<nsIComponentManager> compMgr; nsCOMPtr<nsIComponentManager> compMgr;
NS_GetComponentManager(getter_AddRefs(compMgr)); nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
if (!compMgr) if (compMgr)
return NS_ERROR_FAILURE; status = compMgr->CreateInstance(mCID, mOuter, aIID, aInstancePtr);
nsresult status = compMgr->CreateInstance(mCID, else if (NS_SUCCEEDED(status))
mOuter, status = NS_ERROR_UNEXPECTED;
aIID,
aInstancePtr);
if ( NS_FAILED(status) ) if ( NS_FAILED(status) )
*aInstancePtr = 0; *aInstancePtr = 0;
@ -71,19 +70,18 @@ nsCreateInstanceByContractID::operator()( const nsIID& aIID, void** aInstancePtr
nsresult status; nsresult status;
if ( mContractID ) { if ( mContractID ) {
nsCOMPtr<nsIComponentManager> compMgr; nsCOMPtr<nsIComponentManager> compMgr;
NS_GetComponentManager(getter_AddRefs(compMgr)); status = NS_GetComponentManager(getter_AddRefs(compMgr));
if (!compMgr) if (compMgr)
return NS_ERROR_FAILURE; status = compMgr->CreateInstanceByContractID(mContractID, mOuter,
status = compMgr->CreateInstanceByContractID(mContractID, aIID, aInstancePtr);
mOuter, else if (NS_SUCCEEDED(status))
aIID, status = NS_ERROR_UNEXPECTED;
aInstancePtr);
if (NS_FAILED(status))
*aInstancePtr = 0;
} }
else else
status = NS_ERROR_NULL_POINTER; status = NS_ERROR_NULL_POINTER;
if (NS_FAILED(status))
*aInstancePtr = 0;
if ( mErrorPtr ) if ( mErrorPtr )
*mErrorPtr = status; *mErrorPtr = status;
return status; return status;