Bug 1189369, part 2 - Don't implicitly convert nsMaybeWeakPtr to an nsCOMPtr. r=mak

This is only used in a few places, and it obscures what is happening.
This commit is contained in:
Andrew McCreight 2015-08-04 13:55:01 -07:00
parent bba2a0f5bf
commit 3eefc726cc
3 changed files with 4 additions and 6 deletions

View File

@ -36,10 +36,8 @@ public:
return mPtr == other.mPtr;
}
operator const nsCOMPtr<T>() const { return GetValue(); }
nsISupports* GetRawValue() const { return mPtr.get(); }
protected:
const nsCOMPtr<T> GetValue() const {
return nsCOMPtr<T>(dont_AddRef(static_cast<T*>
(GetValueAs(NS_GET_TEMPLATE_IID(T)))));
@ -99,7 +97,7 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
#define ENUMERATE_WEAKARRAY(array, type, method) \
for (uint32_t array_idx = 0; array_idx < array.Length(); ++array_idx) { \
const nsCOMPtr<type> &e = array.ElementAt(array_idx); \
const nsCOMPtr<type> &e = array.ElementAt(array_idx).GetValue(); \
if (e) \
e->method; \
}

View File

@ -2536,7 +2536,7 @@ nsNavBookmarks::GetObservers(uint32_t* _count,
// Then add the other observers.
for (uint32_t i = 0; i < mObservers.Length(); ++i) {
const nsCOMPtr<nsINavBookmarkObserver> &observer = mObservers.ElementAt(i);
const nsCOMPtr<nsINavBookmarkObserver> &observer = mObservers.ElementAt(i).GetValue();
// Skip nullified weak observers.
if (observer)
observers.AppendElement(observer);

View File

@ -2281,7 +2281,7 @@ nsNavHistory::GetObservers(uint32_t* _count,
// Then add the other observers.
for (uint32_t i = 0; i < mObservers.Length(); ++i) {
const nsCOMPtr<nsINavHistoryObserver> &observer = mObservers.ElementAt(i);
const nsCOMPtr<nsINavHistoryObserver> &observer = mObservers.ElementAt(i).GetValue();
// Skip nullified weak observers.
if (observer)
observers.AppendElement(observer);