From 8880343068d6ca1d04160b4d51b33b31fbdd6a8f Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Tue, 15 Sep 2009 11:55:29 +0300 Subject: [PATCH] Bug 516237, r=enndeakin, sr=neil --HG-- extra : rebase_source : 44179b032971ced59a7d5af9e59724b9d32c41dc --- layout/xul/base/src/tree/src/nsTreeSelection.cpp | 11 +++++++---- layout/xul/base/src/tree/src/nsTreeSelection.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/layout/xul/base/src/tree/src/nsTreeSelection.cpp b/layout/xul/base/src/tree/src/nsTreeSelection.cpp index 1446f3ed0e0..988d8d9cac4 100644 --- a/layout/xul/base/src/tree/src/nsTreeSelection.cpp +++ b/layout/xul/base/src/tree/src/nsTreeSelection.cpp @@ -272,7 +272,7 @@ nsTreeSelection::~nsTreeSelection() 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) @@ -286,8 +286,7 @@ NS_INTERFACE_MAP_END NS_IMETHODIMP nsTreeSelection::GetTree(nsITreeBoxObject * *aTree) { - NS_IF_ADDREF(mTree); - *aTree = mTree; + NS_IF_ADDREF(*aTree = mTree); return NS_OK; } @@ -297,7 +296,11 @@ NS_IMETHODIMP nsTreeSelection::SetTree(nsITreeBoxObject * aTree) mSelectTimer->Cancel(); mSelectTimer = nsnull; } - mTree = aTree; // WEAK + + // Make sure aTree really implements nsITreeBoxObject and nsIBoxObject! + nsCOMPtr bo = do_QueryInterface(aTree); + mTree = do_QueryInterface(bo); + NS_ENSURE_STATE(mTree == aTree); return NS_OK; } diff --git a/layout/xul/base/src/tree/src/nsTreeSelection.h b/layout/xul/base/src/tree/src/nsTreeSelection.h index 2f15ef16c7f..a35e4ff6e94 100644 --- a/layout/xul/base/src/tree/src/nsTreeSelection.h +++ b/layout/xul/base/src/tree/src/nsTreeSelection.h @@ -68,7 +68,7 @@ protected: protected: // Members - nsITreeBoxObject* mTree; // [Weak]. The tree will hold on to us through the view and let go when it dies. + nsCOMPtr 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.