]> git.lyx.org Git - lyx.git/commitdiff
Fixed a memory leak when deleting cache.second (LyXText) and reusing it
authorJürgen Vigna <jug@sad.it>
Thu, 9 Nov 2000 15:22:34 +0000 (15:22 +0000)
committerJürgen Vigna <jug@sad.it>
Thu, 9 Nov 2000 15:22:34 +0000 (15:22 +0000)
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

ChangeLog
src/insets/insettext.C

index 79fccd09c0f3d6c977fbe883796c4202e73c8ff3..cc05646bc9ddff51724bd4ce8dd45d253bbf7530 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * src/frontends/xforms/FormPreferences.C (ColoursLoadBrowser): use
index 0d76778bcee863ffb005905eb04fd7d69ad05fb2..369d9b4ae6a66e87a47f31f407abe50ae53803d9 100644 (file)
@@ -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<InsetText *>(this));
     lt->init(bv);