clear out result in |do_QueryReferent| on error; assert in |NS_GetWeakReference| if the source object doesn't support weak references; also return NS_ERROR_NO_INTERFACE in release builds. r=pinkerton
git-svn-id: svn://10.0.0.236/trunk@54197 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
499fce381e
commit
ba8f7bc4e6
@ -30,7 +30,10 @@ nsQueryReferent::operator()( const nsIID& aIID, void** answer ) const
|
||||
{
|
||||
nsresult status;
|
||||
if ( mWeakPtr )
|
||||
status = mWeakPtr->QueryReferent(aIID, answer);
|
||||
{
|
||||
if ( !NS_SUCCEEDED(status = mWeakPtr->QueryReferent(aIID, answer)) )
|
||||
*answer = 0;
|
||||
}
|
||||
else
|
||||
status = NS_ERROR_NULL_POINTER;
|
||||
|
||||
@ -39,7 +42,7 @@ nsQueryReferent::operator()( const nsIID& aIID, void** answer ) const
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_COM nsIWeakReference *
|
||||
NS_COM nsIWeakReference*
|
||||
NS_GetWeakReference( nsISupports* aInstance, nsresult* aResult )
|
||||
{
|
||||
nsresult status;
|
||||
@ -47,10 +50,10 @@ NS_GetWeakReference( nsISupports* aInstance, nsresult* aResult )
|
||||
aResult = &status;
|
||||
|
||||
nsCOMPtr<nsISupportsWeakReference> factoryP = do_QueryInterface(aInstance, aResult);
|
||||
NS_ASSERTION(factoryP, "Did you know you were calling |NS_GetWeakReference()| on something that doesn't support weak references?");
|
||||
|
||||
nsIWeakReference* weakP = 0;
|
||||
if ( factoryP )
|
||||
status = factoryP->GetWeakReference(&weakP);
|
||||
status = factoryP ? factoryP->GetWeakReference(&weakP) : NS_ERROR_NO_INTERFACE;
|
||||
return weakP;
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,10 @@ nsQueryReferent::operator()( const nsIID& aIID, void** answer ) const
|
||||
{
|
||||
nsresult status;
|
||||
if ( mWeakPtr )
|
||||
status = mWeakPtr->QueryReferent(aIID, answer);
|
||||
{
|
||||
if ( !NS_SUCCEEDED(status = mWeakPtr->QueryReferent(aIID, answer)) )
|
||||
*answer = 0;
|
||||
}
|
||||
else
|
||||
status = NS_ERROR_NULL_POINTER;
|
||||
|
||||
@ -39,7 +42,7 @@ nsQueryReferent::operator()( const nsIID& aIID, void** answer ) const
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_COM nsIWeakReference *
|
||||
NS_COM nsIWeakReference*
|
||||
NS_GetWeakReference( nsISupports* aInstance, nsresult* aResult )
|
||||
{
|
||||
nsresult status;
|
||||
@ -47,10 +50,10 @@ NS_GetWeakReference( nsISupports* aInstance, nsresult* aResult )
|
||||
aResult = &status;
|
||||
|
||||
nsCOMPtr<nsISupportsWeakReference> factoryP = do_QueryInterface(aInstance, aResult);
|
||||
NS_ASSERTION(factoryP, "Did you know you were calling |NS_GetWeakReference()| on something that doesn't support weak references?");
|
||||
|
||||
nsIWeakReference* weakP = 0;
|
||||
if ( factoryP )
|
||||
status = factoryP->GetWeakReference(&weakP);
|
||||
status = factoryP ? factoryP->GetWeakReference(&weakP) : NS_ERROR_NO_INTERFACE;
|
||||
return weakP;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user