]> git.lyx.org Git - features.git/commitdiff
Fix the rest of bug 5010.
authorRichard Heck <rgheck@comcast.net>
Wed, 9 Jul 2008 21:27:15 +0000 (21:27 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 9 Jul 2008 21:27:15 +0000 (21:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25523 a592a061-630c-0410-9148-cb99ea01b6c8

src/CutAndPaste.cpp

index 761a107b6ad8be1b83054f49b6fc91b8f384457a..8f12370a6b8c13fda861bed1b2e0d8a22463db5a 100644 (file)
@@ -360,7 +360,12 @@ void putClipboard(ParagraphList const & paragraphs,
 {
        // For some strange reason gcc 3.2 and 3.3 do not accept
        // Buffer buffer(string(), false);
-       Buffer buffer("", false);
+       // This needs to be static to avoid a memory leak. When a Buffer is
+       // constructed, it constructs a BufferParams, which in turn constructs
+       // a DocumentClass, via new, that is never deleted. If we were to go to
+       // some kind of garbage collection there, or a shared_ptr, then this
+       // would not be needed.
+       static Buffer buffer("", false);
        buffer.setUnnamed(true);
        buffer.paragraphs() = paragraphs;
        buffer.params().setDocumentClass(docclass);
@@ -369,6 +374,8 @@ void putClipboard(ParagraphList const & paragraphs,
                theClipboard().put(lyx.str(), plaintext);
        else
                theClipboard().put(string(), plaintext);
+       // Save that memory
+       buffer.paragraphs() = ParagraphList();
 }