forked from mirrors/gecko-dev
Bug 1860952 warn when nsMaybeWeakPtr::GetValue() returns null for unexpected reasons r=xpcom-reviewers,mccr8
such as failure to implement QueryInterface to T or nsISupportsWeakReference. Null return values are assumed to either represent an object that no longer exists or no object, and so these failures are not detected elsewhere. Differential Revision: https://phabricator.services.mozilla.com/D191827
This commit is contained in:
parent
49f78e27b7
commit
0bea1b1f27
1 changed files with 8 additions and 10 deletions
|
|
@ -127,20 +127,18 @@ const nsCOMPtr<T> nsMaybeWeakPtr<T>::GetValue() const {
|
|||
|
||||
if (mWeak) {
|
||||
nsCOMPtr<nsIWeakReference> weakRef = do_QueryInterface(mPtr);
|
||||
if (weakRef) {
|
||||
ref = do_QueryReferent(weakRef, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return ref;
|
||||
}
|
||||
if (NS_WARN_IF(!weakRef)) {
|
||||
return nullptr;
|
||||
}
|
||||
ref = do_QueryReferent(weakRef, &rv);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv) || rv == NS_ERROR_NULL_POINTER,
|
||||
"QueryReferent failed with non-null pointer");
|
||||
} else {
|
||||
ref = do_QueryInterface(mPtr, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return ref;
|
||||
}
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"QueryInterface failed with non-null pointer");
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return ref;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
Loading…
Reference in a new issue