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