diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-10-13 10:02:08 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-10-15 04:52:52 +0200 |
commit | f8dada570ba03b6761a41a074063f2d306989232 (patch) | |
tree | 964e2460408f2deae4353d60c0520a931fcd3ade /sc | |
parent | fix the problem in the right method (diff) | |
download | core-f8dada570ba03b6761a41a074063f2d306989232.tar.gz core-f8dada570ba03b6761a41a074063f2d306989232.zip |
fix memory leak in note handling
Change-Id: I55a7673aff8e23f59ccb99ea73a102df215ba599
Diffstat (limited to 'sc')
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/inc/postit.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/postit.cxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 2 |
4 files changed, 7 insertions, 8 deletions
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 649a6fca0b4f..2203364ad29a 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -44,7 +44,6 @@ endif $(eval $(call gb_Module_add_check_targets,sc,\ CppunitTest_sc_ucalc \ - CppunitTest_sc_rangelst_test \ )) # Disabled to allow the check tinderbox execute the sd tests diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx index 0db2a9fc1f69..f9c22866fb9f 100644 --- a/sc/inc/postit.hxx +++ b/sc/inc/postit.hxx @@ -266,10 +266,11 @@ private: typedef std::map<ScAddress2D, ScPostIt*> ScNoteMap; ScNoteMap maNoteMap; + ScNotes(const ScNotes& rNotes); + ScNotes operator=(const ScNotes& rNotes); ScDocument* mpDoc; public: ScNotes(ScDocument* pDoc); - ScNotes(const ScNotes& rNotes); ~ScNotes(); typedef ScNoteMap::iterator iterator; @@ -306,7 +307,7 @@ public: void clear(); - ScNotes* clone(ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bCloneNoteCaption, SCTAB nTab); + void clone(ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bCloneNoteCaption, SCTAB nTab, ScNotes& rTarget); void CopyFromClip(const ScNotes& maNotes, ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCsCOL nDx, SCsROW nDy, SCTAB nTab, bool bCloneCaption); void erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bForgetCaption = false); diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 97ab523406a8..4f9c21a49e97 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -1057,9 +1057,9 @@ void ScNotes::clear() maNoteMap.clear(); } -ScNotes* ScNotes::clone(ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bCloneNoteCaption, SCTAB nTab) +void ScNotes::clone(ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bCloneNoteCaption, SCTAB nTab, ScNotes& rTarget) { - ScNotes* pNotes = new ScNotes(pDoc); + rTarget.clear(); for (ScNotes::iterator itr = maNoteMap.begin(); itr != maNoteMap.end(); ++itr) { SCCOL nCol = itr->first.first; @@ -1067,10 +1067,9 @@ ScNotes* ScNotes::clone(ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, if (nCol >= nCol1 && nCol <= nCol2 && nRow >= nRow1 && nRow <= nRow2) { - pNotes->insert(nCol, nRow, itr->second->Clone( ScAddress(nCol, nRow, nTab),*pDoc, ScAddress(nCol, nRow, nTab), bCloneNoteCaption)); + rTarget.insert(nCol, nRow, itr->second->Clone( ScAddress(nCol, nRow, nTab), *pDoc, ScAddress(nCol, nRow, nTab), bCloneNoteCaption)); } } - return pNotes; } void ScNotes::CopyFromClip(const ScNotes& rNotes, ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCsCOL nDx, SCsROW nDy, SCTAB nTab, bool bCloneCaption) diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 3da04e308f03..2a51d544d31b 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -611,7 +611,7 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, pTable->mpRangeName = new ScRangeName(*mpRangeName); // notes - pTable->maNotes = *maNotes.clone(pTable->pDocument, nCol1, nRow1, nCol2, nRow2, bCloneNoteCaptions, nTab); + maNotes.clone(pTable->pDocument, nCol1, nRow1, nCol2, nRow2, bCloneNoteCaptions, nTab, pTable->maNotes); SCCOL i; |