>>>>> "Juergen" == Juergen Vigna <[EMAIL PROTECTED]> writes:

>> - 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?

Juergen> I'm pretty sure I know now where we leak (and where we ALWAYS
Juergen> leaked) with undo/redo. The problem is that we don't delete
Juergen> the paragraphs we substitute.

First the good news: you patch seems to do the right thing, as
LeakTracer does not complain anymore!

But I did not apply it because there is also the bad news: if you
insert two paragraphs in an empty document, like
--
a
b
--
and then undo twice, you will get a crash in 

                // put the new stuff in the list if there is one
                if (tmppar3){
                        if (before)
                                before->next(tmppar3);
                        else
HERE===>                        bv->text->ownerParagraph(tmppar3->id(), tmppar3);
                        tmppar3->previous(before);
                } else {


This is because ownerParagraph calls getParFromID and this searches
for a paragraph by scanning from buffer()->paragraph. But since we
just changed the first paragraph of the document (and even deleted
it), this pointer is not valid anymore.

So the question is: when we undo the first paragraph of a buffer is
there some code which updates buffer->paragraph? Or where shall it be.

Looks like a bug that has always be there.

JMarc

Reply via email to