Kaydet (Commit) f8dada57 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

fix memory leak in note handling

Change-Id: I55a7673aff8e23f59ccb99ea73a102df215ba599
üst 262079b2
......@@ -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
......
......@@ -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);
......
......@@ -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)
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment