Fixed: <rdar://problem/3864536> crash copying text from other apps and pasting in...
authorcblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2004 01:53:43 +0000 (01:53 +0000)
committercblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2004 01:53:43 +0000 (01:53 +0000)
        Reviewed by hyatt.

        * khtml/editing/markup.cpp:
        (khtml::createFragmentFromText): ref and deref the fragment since calling appendChild can completely deref it

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/markup.cpp

index ea9dfbe15897a262c6aba2c48eebc304001d1b4b..c40db4f2c993de5ba18cdc71acda76cb6b9ca6f0 100644 (file)
@@ -1,3 +1,12 @@
+2004-12-14  Chris Blumenberg  <cblu@apple.com>
+
+       Fixed: <rdar://problem/3864536> crash copying text from other apps and pasting in a sticky in dashboard
+
+        Reviewed by hyatt.
+
+        * khtml/editing/markup.cpp:
+        (khtml::createFragmentFromText): ref and deref the fragment since calling appendChild can completely deref it
+
 2004-12-14  David Hyatt  <hyatt@apple.com>
 
        Fix for 3785211. Make sure to do a layout with the old position before doing a layout after changing to the new position.
index 6cb1aaa60d709a96053a35a2f79c4de508de6252..ed4fa4c00939bba5eea3d9da95f9b3e8a67e0f62 100644 (file)
@@ -379,6 +379,8 @@ DOM::DocumentFragmentImpl *createFragmentFromText(DOM::DocumentImpl *document, c
         return 0;
 
     DocumentFragmentImpl *fragment = document->createDocumentFragment();
+    fragment->ref();
+    
     QString string = text;
 
     // Replace tabs with four plain spaces.
@@ -435,6 +437,12 @@ DOM::DocumentFragmentImpl *createFragmentFromText(DOM::DocumentImpl *document, c
         }
     }
     
+    // Trick to get the fragment back to the floating state, with 0
+    // refs but not destroyed.
+    fragment->setParent(document);
+    fragment->deref();
+    fragment->setParent(0);
+    
     return fragment;
 }