Fix for bug 682539 (Add nsTreeColumn::mNext to CC). r=smaug.
authorPeter Van der Beken <peterv@propagandism.org>
Sun, 28 Aug 2011 16:07:26 +0200
changeset 76013 7c905a200bcc1f914e867a104f9256dcf8c4e37a
parent 76012 500c2ddb52c1b8d457c72480f2c1f74212860a8f
child 76014 a12d726a586808a6de30983a9d38e4a69f0de795
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerssmaug
bugs682539
milestone9.0a1
Fix for bug 682539 (Add nsTreeColumn::mNext to CC). r=smaug.
layout/xul/base/src/tree/src/nsTreeColumns.cpp
layout/xul/base/src/tree/src/nsTreeColumns.h
--- a/layout/xul/base/src/tree/src/nsTreeColumns.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeColumns.cpp
@@ -50,36 +50,45 @@
 #include "nsINodeInfo.h"
 #include "nsContentUtils.h"
 #include "nsTreeBodyFrame.h"
 
 // Column class that caches all the info about our column.
 nsTreeColumn::nsTreeColumn(nsTreeColumns* aColumns, nsIContent* aContent)
   : mContent(aContent),
     mColumns(aColumns),
-    mNext(nsnull),
     mPrevious(nsnull)
 {
   NS_ASSERTION(aContent &&
                aContent->NodeInfo()->Equals(nsGkAtoms::treecol,
                                             kNameSpaceID_XUL),
                "nsTreeColumn's content must be a <xul:treecol>");
 
   Invalidate();
 }
 
 nsTreeColumn::~nsTreeColumn()
 {
   if (mNext) {
     mNext->SetPrevious(nsnull);
-    NS_RELEASE(mNext);
   }
 }
 
-NS_IMPL_CYCLE_COLLECTION_1(nsTreeColumn, mContent)
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsTreeColumn)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTreeColumn)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContent)
+  if (tmp->mNext) {
+    tmp->mNext->SetPrevious(nsnull);
+    NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNext)
+  }
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsTreeColumn)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContent)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNext)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTreeColumn)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeColumn)
 
 DOMCI_DATA(TreeColumn, nsTreeColumn)
 
 // QueryInterface implementation for nsTreeColumn
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeColumn)
--- a/layout/xul/base/src/tree/src/nsTreeColumns.h
+++ b/layout/xul/base/src/tree/src/nsTreeColumns.h
@@ -105,17 +105,17 @@ protected:
 
   PRInt8 GetCropStyle() { return mCropStyle; }
   PRInt32 GetTextAlignment() { return mTextAlignment; }
 
   nsTreeColumn* GetNext() { return mNext; }
   nsTreeColumn* GetPrevious() { return mPrevious; }
   void SetNext(nsTreeColumn* aNext) {
     NS_ASSERTION(!mNext, "already have a next sibling");
-    NS_IF_ADDREF(mNext = aNext);
+    mNext = aNext;
   }
   void SetPrevious(nsTreeColumn* aPrevious) { mPrevious = aPrevious; }
 
 private:
   /**
    * Non-null nsIContent for the associated <treecol> element.
    */
   nsCOMPtr<nsIContent> mContent;
@@ -133,17 +133,17 @@ private:
   PRPackedBool mIsSelectable;
   PRPackedBool mOverflow;
 
   PRInt16 mType;
 
   PRInt8 mCropStyle;
   PRInt8 mTextAlignment;
 
-  nsTreeColumn* mNext;
+  nsRefPtr<nsTreeColumn> mNext;
   nsTreeColumn* mPrevious;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeColumn, NS_TREECOLUMN_IMPL_CID)
 
 class nsTreeColumns : public nsITreeColumns {
 public:
   nsTreeColumns(nsITreeBoxObject* aTree);