Bug 516237, r=enndeakin, sr=neil
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 15 Sep 2009 11:55:29 +0300
changeset 32486 5b6c7bdfae3d7b60ba7d85e9ca25ea7482884b41
parent 32485 9503c03ba3558478aec010ce258b1b8a107d6aee
child 32487 36a582d5c645a8c69590cc837bfeb089f7c8cb6b
push id9112
push useropettay@mozilla.com
push dateTue, 15 Sep 2009 09:23:25 +0000
treeherdermozilla-central@5b6c7bdfae3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, neil
bugs516237
milestone1.9.3a1pre
Bug 516237, r=enndeakin, sr=neil
layout/xul/base/src/tree/src/nsTreeSelection.cpp
layout/xul/base/src/tree/src/nsTreeSelection.h
--- a/layout/xul/base/src/tree/src/nsTreeSelection.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeSelection.cpp
@@ -267,42 +267,45 @@ nsTreeSelection::nsTreeSelection(nsITree
 
 nsTreeSelection::~nsTreeSelection()
 {
   delete mFirstRange;
   if (mSelectTimer)
     mSelectTimer->Cancel();
 }
 
-NS_IMPL_CYCLE_COLLECTION_1(nsTreeSelection, mCurrentColumn)
+NS_IMPL_CYCLE_COLLECTION_2(nsTreeSelection, mTree, mCurrentColumn)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTreeSelection)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeSelection)
 
 // QueryInterface implementation for nsBoxObject
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeSelection)
   NS_INTERFACE_MAP_ENTRY(nsITreeSelection)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TreeSelection)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP nsTreeSelection::GetTree(nsITreeBoxObject * *aTree)
 {
-  NS_IF_ADDREF(mTree);
-  *aTree = mTree;
+  NS_IF_ADDREF(*aTree = mTree);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeSelection::SetTree(nsITreeBoxObject * aTree)
 {
   if (mSelectTimer) {
     mSelectTimer->Cancel();
     mSelectTimer = nsnull;
   }
-  mTree = aTree; // WEAK
+
+  // Make sure aTree really implements nsITreeBoxObject and nsIBoxObject!
+  nsCOMPtr<nsIBoxObject> bo = do_QueryInterface(aTree);
+  mTree = do_QueryInterface(bo);
+  NS_ENSURE_STATE(mTree == aTree);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeSelection::GetSingle(PRBool* aSingle)
 {
   if (!mTree)
     return NS_ERROR_NULL_POINTER;
 
--- a/layout/xul/base/src/tree/src/nsTreeSelection.h
+++ b/layout/xul/base/src/tree/src/nsTreeSelection.h
@@ -63,17 +63,17 @@ public:
   friend struct nsTreeRange;
 
 protected:
   nsresult FireOnSelectHandler();
   static void SelectCallback(nsITimer *aTimer, void *aClosure);
 
 protected:
   // Members
-  nsITreeBoxObject* mTree; // [Weak]. The tree will hold on to us through the view and let go when it dies.
+  nsCOMPtr<nsITreeBoxObject> mTree; // The tree will hold on to us through the view and let go when it dies.
 
   PRBool mSuppressed; // Whether or not we should be firing onselect events.
   PRInt32 mCurrentIndex; // The item to draw the rect around. The last one clicked, etc.
   nsCOMPtr<nsITreeColumn> mCurrentColumn;
   PRInt32 mShiftSelectPivot; // Used when multiple SHIFT+selects are performed to pivot on.
 
   nsTreeRange* mFirstRange; // Our list of ranges.