From: Jürgen Vigna Date: Thu, 9 Nov 2000 15:22:34 +0000 (+0000) Subject: Fixed a memory leak when deleting cache.second (LyXText) and reusing it X-Git-Tag: 1.6.10~21830 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=db2fe3221a23a448d52c118f9430f96de1eeb7c2;p=lyx.git 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 --- diff --git a/ChangeLog b/ChangeLog index 79fccd09c0..cc05646bc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-11-09 Juergen Vigna + + * 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 * src/frontends/xforms/FormPreferences.C (ColoursLoadBrowser): use diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 0d76778bce..369d9b4ae6 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -114,8 +114,10 @@ InsetText::~InsetText() { // delete all instances of LyXText before deleting the paragraps used // 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; + (*cit).second = 0; + } LyXParagraph * p = par->next; delete par; while(p) { @@ -130,8 +132,10 @@ void InsetText::clear() { // delete all instances of LyXText before deleting the paragraps used // 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; + (*cit).second = 0; + } LyXParagraph * p = par->next; delete par; while(p) { @@ -177,8 +181,10 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) // delete all instances of LyXText before deleting the paragraps used // 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; + (*cit).second = 0; + } LyXParagraph * p = par->next; delete par; @@ -1390,8 +1396,10 @@ void InsetText::SetParagraphData(LyXParagraph *p) { // delete all instances of LyXText before deleting the paragraps used // 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; + (*cit).second = 0; + } LyXParagraph * np; if (par) { @@ -1488,7 +1496,7 @@ Row * InsetText::crow(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]; LyXText * lt = new LyXText(const_cast(this)); lt->init(bv);