From 663043fd22eeec26761dccc7d25307aba65476e8 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 9 Jul 2008 21:27:15 +0000 Subject: [PATCH] Fix the rest of bug 5010. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25523 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/CutAndPaste.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 761a107b6a..8f12370a6b 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -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(); }