Reviewed by Anders.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jul 2006 09:50:17 +0000 (09:50 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jul 2006 09:50:17 +0000 (09:50 +0000)
        - fix ~3000 Node leaks on the editing tests

        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::moveParagraphs): put a newly created Range in a RefPtr
        to avoid leaking it, as this leaks the whole document.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15183 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/editing/CompositeEditCommand.cpp

index 70375d27790a47347af4e97f94129c625fa60c27..a3024a2a8d2387a38d6f4a01c5a008bf9a3d24c7 100644 (file)
@@ -1,3 +1,13 @@
+2006-07-06  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+
+        - fix ~3000 Node leaks on the editing tests
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::moveParagraphs): put a newly created Range in a RefPtr
+        to avoid leaking it, as this leaks the whole document.
+
 2006-07-06  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Anders.
index d741bfec5167d6812565658ba219414cbe20a066..b2aeb93eae2f123be40e6cdf4836ec80cb2c3cce 100644 (file)
@@ -687,7 +687,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     
     setEndingSelection(Selection(start, end, DOWNSTREAM));
     deleteSelection(false, false);
-    
+
     ASSERT(destination.deepEquivalent().node()->inDocument());
     
     // Deleting a paragraph leaves a placeholder (it always does when a whole paragraph is deleted).
@@ -708,7 +708,8 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     if (beforeParagraph.isNotNull() && !isEndOfParagraph(beforeParagraph))
         insertNodeAt(createBreakElement(document()).get(), beforeParagraph.deepEquivalent().node(), beforeParagraph.deepEquivalent().offset());
         
-    destinationIndex = TextIterator::rangeLength(new Range(document(), Position(document(), 0), destination.deepEquivalent()));
+    RefPtr<Range> startToDestinationRange(new Range(document(), Position(document(), 0), destination.deepEquivalent()));
+    destinationIndex = TextIterator::rangeLength(startToDestinationRange.get());
     
     setEndingSelection(destination);
     EditCommandPtr cmd(new ReplaceSelectionCommand(document(), fragment.get(), true, false, !preserveStyle, true));