Bug 967364: Privatize already_AddRefed::mRawPtr. r=bsmedberg

This commit is contained in:
Kyle Huey 2014-03-15 12:00:15 -07:00
parent c547e55be7
commit 2fd18dbde7
2 changed files with 11 additions and 10 deletions

View File

@ -926,7 +926,7 @@ class nsRefPtr
template <typename I>
nsRefPtr( const already_AddRefed<I>& aSmartPtr )
: mRawPtr(aSmartPtr.mRawPtr)
: mRawPtr(aSmartPtr.take())
// construct from |dont_AddRef(expr)|
{
}
@ -962,7 +962,7 @@ class nsRefPtr
operator=( const already_AddRefed<I>& rhs )
// assign from |dont_AddRef(expr)|
{
assign_assuming_AddRef(rhs.mRawPtr);
assign_assuming_AddRef(rhs.take());
return *this;
}

View File

@ -207,6 +207,7 @@ struct already_AddRefed
return already_AddRefed<U>(tmp);
}
private:
T* mRawPtr;
};
@ -554,22 +555,22 @@ class nsCOMPtr MOZ_FINAL
}
nsCOMPtr( const already_AddRefed<T>& aSmartPtr )
: NSCAP_CTOR_BASE(aSmartPtr.mRawPtr)
: NSCAP_CTOR_BASE(aSmartPtr.take())
// construct from |dont_AddRef(expr)|
{
NSCAP_LOG_ASSIGNMENT(this, aSmartPtr.mRawPtr);
NSCAP_LOG_ASSIGNMENT(this, mRawPtr);
NSCAP_ASSERT_NO_QUERY_NEEDED();
}
template<typename U>
nsCOMPtr( const already_AddRefed<U>& aSmartPtr )
: NSCAP_CTOR_BASE(static_cast<T*>(aSmartPtr.mRawPtr))
: NSCAP_CTOR_BASE(static_cast<T*>(aSmartPtr.take()))
// construct from |dont_AddRef(expr)|
{
// But make sure that U actually inherits from T
static_assert(mozilla::IsBaseOf<T, U>::value,
"U is not a subclass of T");
NSCAP_LOG_ASSIGNMENT(this, static_cast<T*>(aSmartPtr.mRawPtr));
NSCAP_LOG_ASSIGNMENT(this, static_cast<T*>(mRawPtr));
NSCAP_ASSERT_NO_QUERY_NEEDED();
}
@ -659,7 +660,7 @@ class nsCOMPtr MOZ_FINAL
// Make sure that U actually inherits from T
static_assert(mozilla::IsBaseOf<T, U>::value,
"U is not a subclass of T");
assign_assuming_AddRef(static_cast<T*>(rhs.mRawPtr));
assign_assuming_AddRef(static_cast<T*>(rhs.take()));
NSCAP_ASSERT_NO_QUERY_NEEDED();
return *this;
}
@ -895,10 +896,10 @@ class nsCOMPtr<nsISupports>
}
nsCOMPtr( const already_AddRefed<nsISupports>& aSmartPtr )
: nsCOMPtr_base(aSmartPtr.mRawPtr)
: nsCOMPtr_base(aSmartPtr.take())
// construct from |dont_AddRef(expr)|
{
NSCAP_LOG_ASSIGNMENT(this, aSmartPtr.mRawPtr);
NSCAP_LOG_ASSIGNMENT(this, mRawPtr);
}
nsCOMPtr( const nsQueryInterface qi )
@ -981,7 +982,7 @@ class nsCOMPtr<nsISupports>
operator=( const already_AddRefed<nsISupports>& rhs )
// assign from |dont_AddRef(expr)|
{
assign_assuming_AddRef(rhs.mRawPtr);
assign_assuming_AddRef(rhs.take());
return *this;
}