On Wed, Jul 09, 2008 at 03:23:09PM -0400, rgheck wrote: > > So, here's the deal with 5010. As noted before, DocumentClass objects get > created via new() whenever makeDocumentClass() is called. This happens > whenever a BufferParams object is created, which was the original problem: > Such objects were getting created in the undo stuff. Now they're not. But > they get created for other strange reasons, such as in putClipboard(), > where we find this code: > > void putClipboard(ParagraphList const & paragraphs, > DocumentClass const * const docclass, docstring const & plaintext) > { > // For some strange reason gcc 3.2 and 3.3 do not accept > // Buffer buffer(string(), false); > Buffer buffer("", false); > buffer.setUnnamed(true); > buffer.paragraphs() = paragraphs; > buffer.params().setDocumentClass(docclass); > ostringstream lyx; > if (buffer.write(lyx)) > theClipboard().put(lyx.str(), plaintext); > else > theClipboard().put(string(), plaintext); > } > > > Right here, a possible solution would be to make the Buffer static: We'd > lose a bit of memory that way, but not a ton, and it'd save having to > recreate it all the time, anyway. Since we'd only create the BufferParams > once, then we wouldn't create tons of DocumentClass objects, so nothing > leaks. > > That said, this is just one problem, and there may be others. A more > general solution would be to use some kind of shared pointer here. I was > trying to avoid doing so, and that's why I was using DocumentClassBundle, > but maybe at this point we should just go with boost::shared_ptr.
Within Undo.cpp that should be fine. I just do not want to leak the #includes to whatever uses #include "Undo.h". Andre' >