From aa94b17208a5512a344301345f26a9418f943a00 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 24 Jan 2014 21:29:54 -0500 Subject: [PATCH] Stop leaking all ScPostIt instances. And re-implement correct swapping of two ScPostIt instances during sort. (cherry picked from commit ab05317c79f665bcf9d5cff7b8312ce6963ff969) Change-Id: Ifbf120aae594342ae0b7c5760f771c53092c8022 Reviewed-on: https://gerrit.libreoffice.org/7641 Reviewed-by: Markus Mohrhard Tested-by: Markus Mohrhard (cherry picked from commit b5f9c2be36f935f0009c2d7c40f7fadebf0b7ef8) Reviewed-on: https://gerrit.libreoffice.org/7695 Reviewed-by: Michael Meeks Reviewed-by: Fridrich Strba Tested-by: Fridrich Strba --- sc/inc/mtvelements.hxx | 2 +- sc/source/core/data/column2.cxx | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx index 0fcafdecce98..3eb5527b8eaf 100644 --- a/sc/inc/mtvelements.hxx +++ b/sc/inc/mtvelements.hxx @@ -65,7 +65,7 @@ const mdds::mtv::element_t element_type_empty = mdds::mtv::element_type_empty; /// Custom element blocks. -typedef mdds::mtv::default_element_block cellnote_block; +typedef mdds::mtv::noncopyable_managed_element_block cellnote_block; typedef mdds::mtv::noncopyable_managed_element_block broadcaster_block; typedef mdds::mtv::default_element_block celltextattr_block; typedef mdds::mtv::default_element_block string_block; diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 2adf63c83271..9004bbbfbd97 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1902,8 +1902,6 @@ void ScColumn::SwapCellNotes( SCROW nRow1, SCROW nRow2 ) if (aPos2.first == maCellNotes.end()) return; - ScPostIt* aNote; - sc::CellNoteStoreType::iterator it1 = aPos1.first, it2 = aPos2.first; if (it1->type == it2->type) { @@ -1917,10 +1915,10 @@ void ScColumn::SwapCellNotes( SCROW nRow1, SCROW nRow2 ) sc::cellnote_block::at(*it2->data, aPos2.second)); //update Note caption with position - aNote = sc::cellnote_block::at(*it1->data, aPos1.second); - aNote->UpdateCaptionPos(ScAddress(nCol,nRow2,nTab)); - aNote = sc::cellnote_block::at(*it2->data, aPos2.second); - aNote->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab)); + ScPostIt* pNote = sc::cellnote_block::at(*it1->data, aPos1.second); + pNote->UpdateCaptionPos(ScAddress(nCol,nRow2,nTab)); + pNote = sc::cellnote_block::at(*it2->data, aPos2.second); + pNote->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab)); return; } @@ -1931,19 +1929,18 @@ void ScColumn::SwapCellNotes( SCROW nRow1, SCROW nRow2 ) // row 1 is empty while row 2 is non-empty. ScPostIt* pVal2 = sc::cellnote_block::at(*it2->data, aPos2.second); it1 = maCellNotes.set(it1, nRow1, pVal2); - maCellNotes.set_empty(it1, nRow2, nRow2); + maCellNotes.release(it1, nRow2, pVal2); pVal2->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab)); //update Note caption with position return; } // row 1 is non-empty while row 2 is empty. - ScPostIt* pVal1 = sc::cellnote_block::at(*it1->data, aPos1.second); - it1 = maCellNotes.set_empty(it1, nRow1, nRow1); + ScPostIt* pVal1 = NULL; + it1 = maCellNotes.release(it1, nRow1, pVal1); + assert(pVal1); maCellNotes.set(it1, nRow2, pVal1); pVal1->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab)); //update Note caption with position - - CellStorageModified(); } SvtBroadcaster* ScColumn::GetBroadcaster(SCROW nRow) -- 2.11.4.GIT