deleting NULL is safe

Change-Id: Ief65149bc88ac4ce8badc7dbce818fca0cdcb201
This commit is contained in:
Takeshi Abe 2013-04-09 07:21:20 +09:00
parent 0f9190b1fa
commit c70fc41d6b
17 changed files with 42 additions and 78 deletions

View File

@ -112,10 +112,8 @@ AccessibleShape::AccessibleShape (
AccessibleShape::~AccessibleShape (void)
{
if (mpChildrenManager != NULL)
delete mpChildrenManager;
if (mpText != NULL)
delete mpText;
delete mpChildrenManager;
delete mpText;
OSL_TRACE ("~AccessibleShape");
// Unregistering from the various broadcasters should be unnecessary

View File

@ -70,10 +70,7 @@ SvxRedlinEntry::SvxRedlinEntry()
SvxRedlinEntry::~SvxRedlinEntry()
{
RedlinData* pRedDat=(RedlinData*) GetUserData();
if(pRedDat!=NULL)
{
delete pRedDat;
}
delete pRedDat;
}
// Functions in the inserts Items of SvxRedlinTable
@ -149,8 +146,7 @@ SvxRedlinTable::SvxRedlinTable(SvxSimpleTableContainer& rParent,WinBits nBits)
SvxRedlinTable::~SvxRedlinTable()
{
if(pCommentSearcher!=NULL)
delete pCommentSearcher;
delete pCommentSearcher;
}
StringCompare SvxRedlinTable::ColCompare(SvTreeListEntry* pLeft,SvTreeListEntry* pRight)
@ -301,7 +297,7 @@ void SvxRedlinTable::SetCommentParams( const utl::SearchParam* pSearchPara )
{
if(pSearchPara!=NULL)
{
if(pCommentSearcher!=NULL) delete pCommentSearcher;
delete pCommentSearcher;
pCommentSearcher=new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM );
}

View File

@ -165,8 +165,7 @@ void SvxRectCtl::Resize_Impl()
void SvxRectCtl::InitRectBitmap( void )
{
if( pBitmap )
delete pBitmap;
delete pBitmap;
const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
svtools::ColorConfig aColorConfig;

View File

@ -282,8 +282,7 @@ void SvxHyperlinkItem::SetMacro( sal_uInt16 nEvent, const SvxMacro& rMacro )
void SvxHyperlinkItem::SetMacroTable( const SvxMacroTableDtor& rTbl )
{
if ( pMacroTable )
delete pMacroTable;
delete pMacroTable;
pMacroTable = new SvxMacroTableDtor ( rTbl );
}

View File

@ -26,7 +26,7 @@ void SdrDragStat::Clear(bool bLeaveOne)
delete aPnts.back();
aPnts.pop_back();
}
if (pUser!=NULL) delete pUser;
delete pUser;
pUser=NULL;
aPnts.clear();
if (bLeaveOne) {

View File

@ -96,9 +96,7 @@ SdrObjEditView::~SdrObjEditView()
{
pTextEditWin = NULL; // so there's no ShowCursor in SdrEndTextEdit
if (IsTextEdit()) SdrEndTextEdit();
if (pTextEditOutliner!=NULL) {
delete pTextEditOutliner;
}
delete pTextEditOutliner;
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -217,11 +217,9 @@ _SdrItemBrowserControl::_SdrItemBrowserControl(Window* pParent, WinBits nBits):
_SdrItemBrowserControl::~_SdrItemBrowserControl()
{
if(pEditControl)
delete pEditControl;
delete pEditControl;
if(pAktChangeEntry)
delete pAktChangeEntry;
delete pAktChangeEntry;
Clear();
}

View File

@ -306,8 +306,7 @@ SdrModel::~SdrModel()
OSL_FAIL(aStr.getStr());
}
#endif
if (pAktUndoGroup!=NULL)
delete pAktUndoGroup;
delete pAktUndoGroup;
ClearModel(sal_True);
@ -346,8 +345,7 @@ SdrModel::~SdrModel()
if( mpForbiddenCharactersTable )
mpForbiddenCharactersTable->release();
if(mpNumberFormatter)
delete mpNumberFormatter;
delete mpNumberFormatter;
delete mpImpl->mpUndoFactory;
delete mpImpl;
@ -1515,7 +1513,7 @@ void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
void SdrModel::DeleteMasterPage(sal_uInt16 nPgNum)
{
SdrPage* pPg=RemoveMasterPage(nPgNum);
if (pPg!=NULL) delete pPg;
delete pPg;
}
SdrPage* SdrModel::RemoveMasterPage(sal_uInt16 nPgNum)

View File

@ -275,9 +275,9 @@ SdrObjPlusData::SdrObjPlusData():
SdrObjPlusData::~SdrObjPlusData()
{
if (pBroadcast !=NULL) delete pBroadcast;
if (pUserDataList!=NULL) delete pUserDataList;
if (pGluePoints !=NULL) delete pGluePoints;
delete pBroadcast;
delete pUserDataList;
delete pGluePoints;
}
SdrObjPlusData* SdrObjPlusData::Clone(SdrObject* pObj1) const
@ -484,7 +484,7 @@ SdrObject::~SdrObject()
DBG_DTOR(SdrObject,NULL);
SendUserCall(SDRUSERCALL_DELETE, GetLastBoundRect());
if (pPlusData!=NULL) delete pPlusData;
delete pPlusData;
if(mpProperties)
{

View File

@ -795,11 +795,9 @@ SdrOle2Obj::~SdrOle2Obj()
if ( mpImpl->mbConnected )
Disconnect();
if( pGraphic!=NULL )
delete pGraphic;
delete pGraphic;
if(mpImpl->pGraphicObject!=NULL)
delete mpImpl->pGraphicObject;
delete mpImpl->pGraphicObject;
if(pModifyListener)
{

View File

@ -193,11 +193,9 @@ SdrTextObj::~SdrTextObj()
rOutl.SetTextObj( NULL );
}
if(mpText!=NULL)
delete mpText;
delete mpText;
if (pFormTextBoundRect!=NULL)
delete pFormTextBoundRect;
delete pFormTextBoundRect;
ImpLinkAbmeldung();
}

View File

@ -84,8 +84,7 @@ void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
mpModel->GetHitTestOutliner().SetTextObj( 0 );
}
if( mpOutlinerParaObject )
delete mpOutlinerParaObject;
delete mpOutlinerParaObject;
mpOutlinerParaObject = pTextObject;

View File

@ -301,20 +301,14 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
SdrUndoAttrObj::~SdrUndoAttrObj()
{
if(pUndoSet)
delete pUndoSet;
if(pRedoSet)
delete pRedoSet;
if(pRepeatSet)
delete pRepeatSet;
if(pUndoGroup)
delete pUndoGroup;
if(pTextUndo)
delete pTextUndo;
delete pUndoSet;
delete pRedoSet;
delete pRepeatSet;
delete pUndoGroup;
delete pTextUndo;
// #i8508#
if(pTextRedo)
delete pTextRedo;
delete pTextRedo;
}
void SdrUndoAttrObj::Undo()
@ -331,10 +325,7 @@ void SdrUndoAttrObj::Undo()
{
bHaveToTakeRedoSet = sal_False;
if(pRedoSet)
{
delete pRedoSet;
}
delete pRedoSet;
pRedoSet = new SfxItemSet(pObj->GetMergedItemSet());
@ -603,9 +594,9 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj):
SdrUndoGeoObj::~SdrUndoGeoObj()
{
if (pUndoGeo!=NULL) delete pUndoGeo;
if (pRedoGeo!=NULL) delete pRedoGeo;
if (pUndoGroup!=NULL) delete pUndoGroup;
delete pUndoGeo;
delete pRedoGeo;
delete pUndoGroup;
}
void SdrUndoGeoObj::Undo()
@ -622,7 +613,7 @@ void SdrUndoGeoObj::Undo()
}
else
{
if (pRedoGeo!=NULL) delete pRedoGeo;
delete pRedoGeo;
pRedoGeo=pObj->GetGeoData();
pObj->SetGeoData(*pUndoGeo);
}
@ -639,7 +630,7 @@ void SdrUndoGeoObj::Redo()
}
else
{
if (pUndoGeo!=NULL) delete pUndoGeo;
delete pUndoGeo;
pUndoGeo=pObj->GetGeoData();
pObj->SetGeoData(*pRedoGeo);
}
@ -1095,10 +1086,8 @@ SdrUndoObjSetText::SdrUndoObjSetText(SdrObject& rNewObj, sal_Int32 nText)
SdrUndoObjSetText::~SdrUndoObjSetText()
{
if ( pOldText )
delete pOldText;
if ( pNewText )
delete pNewText;
delete pOldText;
delete pNewText;
}
void SdrUndoObjSetText::AfterSetText()
@ -1495,9 +1484,7 @@ SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg):
SdrUndoDelPage::~SdrUndoDelPage()
{
if (pUndoGroup!=NULL) {
delete pUndoGroup;
}
delete pUndoGroup;
}
void SdrUndoDelPage::Undo()

View File

@ -1584,8 +1584,7 @@ Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName ) throw(Unk
void SAL_CALL Cell::setAllPropertiesToDefault( ) throw (RuntimeException)
{
if( mpProperties )
delete mpProperties;
delete mpProperties;
mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this );
SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner();

View File

@ -224,8 +224,7 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
mxTableModel->setModified(sal_True);
}
if( pUndo )
delete pUndo;
delete pUndo;
}
// -----------------------------------------------------------------------------

View File

@ -482,8 +482,7 @@ void SvxTableController::GetState( SfxItemSet& rSet )
}
nWhich = aIter.NextWhich();
}
if( pSet )
delete pSet;
delete pSet;
}
// --------------------------------------------------------------------

View File

@ -298,8 +298,7 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
mxTableModel->setModified(sal_True);
}
if( pUndo )
delete pUndo;
delete pUndo;
}
// -----------------------------------------------------------------------------