Fixed a memory leak when deleting cache.second (LyXText) and reusing it

later (well Lars you didn't tell me the whole truth ;)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1207 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-11-09 15:22:34 +00:00
parent 1a3ed565d9
commit db2fe3221a
2 changed files with 21 additions and 5 deletions

View File

@ -1,3 +1,11 @@
2000-11-09 Juergen Vigna <jug@sad.it>
* src/insets/insettext.C (~InsetText):
(clear):
(Read):
(SetParagraphData): set cache.second to 0 after deleting it!
(getLyXText): check if cache.second is not 0 if finding it.
2000-11-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 2000-11-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/frontends/xforms/FormPreferences.C (ColoursLoadBrowser): use * src/frontends/xforms/FormPreferences.C (ColoursLoadBrowser): use

View File

@ -114,8 +114,10 @@ InsetText::~InsetText()
{ {
// delete all instances of LyXText before deleting the paragraps used // delete all instances of LyXText before deleting the paragraps used
// by it. // by it.
for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
delete (*cit).second; delete (*cit).second;
(*cit).second = 0;
}
LyXParagraph * p = par->next; LyXParagraph * p = par->next;
delete par; delete par;
while(p) { while(p) {
@ -130,8 +132,10 @@ void InsetText::clear()
{ {
// delete all instances of LyXText before deleting the paragraps used // delete all instances of LyXText before deleting the paragraps used
// by it. // by it.
for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
delete (*cit).second; delete (*cit).second;
(*cit).second = 0;
}
LyXParagraph * p = par->next; LyXParagraph * p = par->next;
delete par; delete par;
while(p) { while(p) {
@ -177,8 +181,10 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
// delete all instances of LyXText before deleting the paragraps used // delete all instances of LyXText before deleting the paragraps used
// by it. // by it.
for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
delete (*cit).second; delete (*cit).second;
(*cit).second = 0;
}
LyXParagraph * p = par->next; LyXParagraph * p = par->next;
delete par; delete par;
@ -1390,8 +1396,10 @@ void InsetText::SetParagraphData(LyXParagraph *p)
{ {
// delete all instances of LyXText before deleting the paragraps used // delete all instances of LyXText before deleting the paragraps used
// by it. // by it.
for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
delete (*cit).second; delete (*cit).second;
(*cit).second = 0;
}
LyXParagraph * np; LyXParagraph * np;
if (par) { if (par) {
@ -1488,7 +1496,7 @@ Row * InsetText::crow(BufferView * bv) const
LyXText * InsetText::getLyXText(BufferView * bv) const LyXText * InsetText::getLyXText(BufferView * bv) const
{ {
if (cache.find(bv) != cache.end()) if ((cache.find(bv) != cache.end()) && cache[bv])
return cache[bv]; return cache[bv];
LyXText * lt = new LyXText(const_cast<InsetText *>(this)); LyXText * lt = new LyXText(const_cast<InsetText *>(this));
lt->init(bv); lt->init(bv);