summaryrefslogtreecommitdiff
path: root/sc/source/ui/undo
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-02-12 11:23:26 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-02-12 12:33:00 -0500
commit0585322e70d3c0f1d26d6bd9c04a388a1ff55abf (patch)
treebd206df6f4f80ab4ea461137deccb6887dc72777 /sc/source/ui/undo
parent117b3a13b82aaac0977fd17ee5b7b63204e659f4 (diff)
Go through all ScEditCell instantiations and fix memory leaks.
Changed the signature of the constructor (one that clones the text object) to take a reference instead of a pointer, to smoke out the callers that use this constructor. Went through all its callers and made changes to either 1) pass ownership to the cell instance (if the text object uses the SfxItemPool instance returned from ScDocument::GetEditPool()), or 2) pass as const reference to make it clear that the instance will get cloned. Change-Id: I669e066d4739536bf8d3b356186503dcdfa303b0
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r--sc/source/ui/undo/undocell.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index a96d1925ee56..b1f7c98e37e4 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -296,7 +296,8 @@ void ScUndoEnterData::Redo()
for (sal_uInt16 i=0; i<nCount; i++)
{
if (pNewEditData)
- pDoc->PutCell( nCol, nRow, pTabs[i], new ScEditCell( pNewEditData,
+ // A clone of pNewEditData will be stored in ScEditCell.
+ pDoc->PutCell( nCol, nRow, pTabs[i], new ScEditCell(*pNewEditData,
pDoc, NULL ) );
else
pDoc->SetString( nCol, nRow, pTabs[i], aNewString );
@@ -661,7 +662,8 @@ ScUndoThesaurus::ScUndoThesaurus( ScDocShell* pNewDocShell,
ScBaseCell* pOldCell;
if ( pUndoTObject )
- pOldCell = new ScEditCell( pUndoTObject, pDocShell->GetDocument(), NULL );
+ // A clone of pUndoTObject will be stored in the cell.
+ pOldCell = new ScEditCell(*pUndoTObject, pDocShell->GetDocument(), NULL);
else
pOldCell = new ScStringCell( aUndoStr );
SetChangeTrack( pOldCell );
@@ -713,7 +715,8 @@ void ScUndoThesaurus::DoChange( sal_Bool bUndo, const String& rStr,
{
if (pCell->GetCellType() == CELLTYPE_EDIT )
{
- ScEditCell* pNewCell = new ScEditCell( pTObj, pDoc, NULL );
+ // A copy of pTObj will be stored in the cell.
+ ScEditCell* pNewCell = new ScEditCell(*pTObj, pDoc, NULL);
pDoc->PutCell( nCol, nRow, nTab, pNewCell );
if ( !bUndo )
SetChangeTrack( pCell );