Ensure that insetlist always contains non-null pointers to insets.

Fix a couple of possible memory leaks.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8546 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-03-27 13:24:16 +00:00
parent 6e600e84f8
commit 3f70e153ee
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2004-03-27 Angus Leeming <leeming@lyx.org>
* paragraph_funcs.C (moveItem): fix memory leaks, ensure that
insetlist always contains non-null pointers to insets.
2004-03-26 Angus Leeming <leeming@lyx.org>
* src/BufferView_pimpl.C:

View File

@ -68,11 +68,15 @@ bool moveItem(Paragraph & from, Paragraph & to,
if (from.getInset(i)) {
// the inset is not in a paragraph anymore
tmpinset = from.insetlist.release(i);
from.insetlist.erase(i);
}
if (!to.insetAllowed(tmpinset->lyxCode()))
if (!to.insetAllowed(tmpinset->lyxCode())) {
delete tmpinset;
return false;
to.insertInset(j, tmpinset, tmpfont);
}
if (tmpinset)
to.insertInset(j, tmpinset, tmpfont);
} else {
if (!to.checkInsertChar(tmpfont))
return false;