maybeweak-crap.patch
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 95 b35cbfa6ad4f8bac97b5a0ae2a3bfc18ed88de35
permissions -rw-r--r--
State as of now

diff --git a/toolkit/components/places/src/nsMaybeWeakPtr.cpp b/toolkit/components/places/src/nsMaybeWeakPtr.cpp
--- a/toolkit/components/places/src/nsMaybeWeakPtr.cpp
+++ b/toolkit/components/places/src/nsMaybeWeakPtr.cpp
@@ -105,7 +105,7 @@ nsMaybeWeakPtrArray_base::RemoveWeakElem
   nsresult rv = supWeakRef->GetWeakReference(getter_AddRefs(weakRef));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  index = array->IndexOf(weakRef);
+  index = array->IndexOf((nsISupports*) weakRef);
   if (index == isupports_type::NoIndex) {
     return NS_ERROR_INVALID_ARG;
   }
diff --git a/toolkit/components/places/src/nsMaybeWeakPtr.h b/toolkit/components/places/src/nsMaybeWeakPtr.h
--- a/toolkit/components/places/src/nsMaybeWeakPtr.h
+++ b/toolkit/components/places/src/nsMaybeWeakPtr.h
@@ -70,18 +70,28 @@ public:
                         )
   nsMaybeWeakPtr(const nsCOMPtr<T> &ref) { mPtr = ref; }
 
+  PRBool operator==(T* other) const {
+    return static_cast<T*>(mPtr) == other;
+  }
+
   PRBool operator==(const nsMaybeWeakPtr<T> &other) const {
     return mPtr == other.mPtr;
   }
 
-  operator const nsCOMPtr<T>() const { return GetValue(); }
+  operator T*() const { return GetValue(); }
 
 protected:
-  const nsCOMPtr<T> GetValue() const {
-    return nsCOMPtr<T>(dont_AddRef(static_cast<T*>
-                                              (GetValueAs(NS_GET_TEMPLATE_IID(T)))));
+  T* GetValue() const {
+    return static_cast<T*>(GetValueAs(NS_GET_TEMPLATE_IID(T)));
   }
 };
+
+template<class T>
+PRBool
+operator==(const nsMaybeWeakPtr<T> &f, const nsCOMPtr<T> &s)
+{
+  return f == s.get();
+}
 
 // nsMaybeWeakPtrArray is an array of MaybeWeakPtr objects, that knows how to
 // grab a weak reference to a given object if requested.  It only allows a