> - Memory leak! Add three paragraphs to an empty document, > each consisting of only one letter (say "a", "b", and "c"); > press "CTRL-Z" -> "c" vanishes; cursor stays in third par (no mem leak); > press "CTRL-Z" again -> "b" vanishes; cursor stays in second par (mem leak) > Pressing CTRL-Z a third time causes additional memory leaks of 240 bytes. > Jean Marc, how about a Purify report?
I'm pretty sure I know now where we leak (and where we ALWAYS leaked) with undo/redo. The problem is that we don't delete the paragraphs we substitute. The code is in textHandleUndo() and IMO we have to change this peace of code: // now remove the old text if there is any if (before != behind || (!behind && !before)) { if (before) tmppar5 = before->next(); else tmppar5 = firstUndoParagraph(bv, undo->number_of_inset_id); tmppar2 = tmppar3; while (tmppar5 && tmppar5 != behind) { tmppar = tmppar5; tmppar5 = tmppar5->next(); // a memory optimization for edit: Only layout information // is stored in the undo. So restore the text informations. if (undo->kind == Undo::EDIT) { tmppar2->setContentsFromPar(tmppar); - tmppar->clearContents(); tmppar2 = tmppar2->next(); } + delete tmppar; } } But I would really like a purify report for this if possible! Jug -- -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ Dr. Jürgen Vigna E-Mail: [EMAIL PROTECTED] Italienallee 13/N Tel/Fax: +39-0471-450260 / +39-0471-450253 I-39100 Bozen Web: http://www.sad.it/~jug -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ Given a choice between grief and nothing, I'd choose grief. -- William Faulkner