Kaydet (Commit) f2326368 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

SwUndoTblNdsChg::pDelSects was used unitialized.

sw/qa/unoapi checks failed because of this.

Changed both pDelSects and pNewSttNds to auto_ptrs to clean up resource handling here;
explicitly made SwUndoTblNdsChg noncopyable to avoid auto_ptr-stealing.
üst 46525507
......@@ -30,11 +30,14 @@
#include <undobj.hxx>
#include <memory>
#include <vector>
#include <set>
#include <swtypes.hxx>
#include <itabenum.hxx>
#include "boost/noncopyable.hpp"
class SfxItemSet;
struct SwSaveRowSpan;
......@@ -171,7 +174,7 @@ public:
void SaveBoxCntnt( const SwTableBox& rBox );
};
class SwUndoTblNdsChg : public SwUndo
class SwUndoTblNdsChg : public SwUndo, private boost::noncopyable
{
_SaveTable* pSaveTbl;
std::set<sal_uLong> aBoxes;
......@@ -182,8 +185,8 @@ class SwUndoTblNdsChg : public SwUndo
_BoxMove(sal_uLong idx, bool moved=false) : index(idx), hasMoved(moved) {};
bool operator<(const _BoxMove other) const { return index < other.index; };
};
std::set<_BoxMove> *pNewSttNds;
SwUndoSaveSections *pDelSects;
std::auto_ptr< std::set<_BoxMove> > pNewSttNds;
std::auto_ptr< SwUndoSaveSections > pDelSects;
long nMin, nMax; // for redo of delete column
sal_uLong nSttNode, nCurrBox;
sal_uInt16 nCount, nRelDiff, nAbsDiff, nSetColType;
......
......@@ -1551,8 +1551,6 @@ SwUndoTblNdsChg::SwUndoTblNdsChg( SwUndoId nAction,
bFlag( bFlg ),
bSameHeight( bSmHght )
{
pNewSttNds = 0;
const SwTable& rTbl = rTblNd.GetTable();
pSaveTbl = new _SaveTable( rTbl );
......@@ -1572,8 +1570,6 @@ SwUndoTblNdsChg::SwUndoTblNdsChg( SwUndoId nAction,
bFlag( sal_False ),
bSameHeight( sal_False )
{
pNewSttNds = 0;
const SwTable& rTbl = rTblNd.GetTable();
pSaveTbl = new _SaveTable( rTbl );
......@@ -1594,11 +1590,6 @@ void SwUndoTblNdsChg::ReNewBoxes( const SwSelBoxes& rBoxes )
SwUndoTblNdsChg::~SwUndoTblNdsChg()
{
delete pSaveTbl;
if( IsDelBox() )
delete pDelSects;
else
delete pNewSttNds;
}
void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
......@@ -1610,7 +1601,7 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
sal_uInt16 i;
OSL_ENSURE( ! IsDelBox(), "falsche Action" );
pNewSttNds = new std::set<_BoxMove>;
pNewSttNds.reset( new std::set<_BoxMove> );
for( n = 0, i = 0; n < rOld.Count(); ++i )
{
......@@ -1663,7 +1654,7 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
const SwTableSortBoxes& rTblBoxes = rTbl.GetTabSortBoxes();
OSL_ENSURE( ! IsDelBox(), "falsche Action" );
pNewSttNds = new std::set<_BoxMove>;
pNewSttNds.reset( new std::set<_BoxMove> );
OSL_ENSURE( rTbl.IsNewModel() || rOld.Count() + nCount * rBoxes.Count() == rTblBoxes.Count(),
"unexpected boxes" );
......@@ -1739,8 +1730,8 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd,
void SwUndoTblNdsChg::SaveSection( SwStartNode* pSttNd )
{
OSL_ENSURE( IsDelBox(), "falsche Action" );
if( !pDelSects )
pDelSects = new SwUndoSaveSections( 10, 5 );
if( pDelSects.get() == NULL )
pDelSects.reset( new SwUndoSaveSections( 10, 5 ) );
SwTableNode* pTblNd = pSttNd->FindTableNode();
SwUndoSaveSection* pSave = new SwUndoSaveSection;
......@@ -1965,7 +1956,7 @@ void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext)
if( pUndo )
{
pDelSects->Insert( pUndo->pDelSects, 0 );
pDelSects->Insert( pUndo->pDelSects.get(), 0 );
pUndo->pDelSects->Remove( 0, pUndo->pDelSects->Count() );
delete pUndo;
......
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