--- 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.