summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-05-31 22:29:14 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-05-31 22:30:40 +0900
commitb32ee047312a49c13a247aa57485fad128f13317 (patch)
treed48f832c0c94ae167de8ec7bd88b30cd95f16295 /sw/source
parentd2d2136f3f1ecfa03713ff4231ad6214ca6a9c33 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I1988d2766d8bdeb5f8a22a5673dcff9b898dd637
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/uibase/wrtsh/select.cxx11
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx7
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx11
3 files changed, 14 insertions, 15 deletions
diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx
index 76a4c2eb8d66..29fa6c402aca 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -39,6 +39,7 @@
#include <crsskip.hxx>
#include <doc.hxx>
#include <wordcountdialog.hxx>
+#include <boost/scoped_ptr.hpp>
namespace com { namespace sun { namespace star { namespace util {
struct SearchOptions;
@@ -128,8 +129,8 @@ long SwWrtShell::SelAll()
LeaveBlockMode();
SwMvContext aMvContext(this);
bool bMoveTable = false;
- SwPosition *pStartPos = 0;
- SwPosition *pEndPos = 0;
+ boost::scoped_ptr<SwPosition> pStartPos;
+ boost::scoped_ptr<SwPosition> pEndPos;
SwShellCrsr* pTmpCrsr = 0;
if( !HasWholeTabSelection() )
{
@@ -138,8 +139,8 @@ long SwWrtShell::SelAll()
pTmpCrsr = getShellCrsr( false );
if( pTmpCrsr )
{
- pStartPos = new SwPosition( *pTmpCrsr->GetPoint() );
- pEndPos = new SwPosition( *pTmpCrsr->GetMark() );
+ pStartPos.reset(new SwPosition( *pTmpCrsr->GetPoint() ));
+ pEndPos.reset(new SwPosition( *pTmpCrsr->GetMark() ));
}
Push();
bool bIsFullSel = !MoveSection( fnSectionCurr, fnSectionStart);
@@ -187,8 +188,6 @@ long SwWrtShell::SelAll()
*pEndPos == *pTmpCrsr->GetPoint() ) ) && !bStartsWithTable)
SwCrsrShell::SttEndDoc(false);
}
- delete pStartPos;
- delete pEndPos;
}
}
EndSelect();
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index b1893be9f54c..dbd8c055eec9 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -102,6 +102,7 @@
#include "PostItMgr.hxx"
#include <sfx2/msgpool.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace sw::mark;
using namespace com::sun::star;
@@ -371,8 +372,8 @@ void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName
OString aCmd(".uno:");
aCmd += pSlot->GetUnoName();
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- SfxAbstractInsertObjectDialog* pDlg =
- pFact->CreateInsertObjectDialog( GetWin(), OStringToOUString( aCmd, RTL_TEXTENCODING_UTF8 ), xStor, &aServerList );
+ boost::scoped_ptr<SfxAbstractInsertObjectDialog> pDlg(
+ pFact->CreateInsertObjectDialog( GetWin(), OStringToOUString( aCmd, RTL_TEXTENCODING_UTF8 ), xStor, &aServerList ));
if ( pDlg )
{
pDlg->Execute();
@@ -383,8 +384,6 @@ void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName
xIconMetaFile.is() ? embed::Aspects::MSOLE_ICON : embed::Aspects::MSOLE_CONTENT );
if ( xIconMetaFile.is() )
xObj.SetGraphicStream( xIconMetaFile, aIconMediaType );
-
- DELETEZ( pDlg );
}
break;
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index ae1d19091d7d..e0cf20bda04a 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -63,6 +63,7 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <xmloff/odffields.hxx>
+#include <boost/scoped_ptr.hpp>
void SwWrtShell::Insert(SwField &rFld)
{
@@ -192,13 +193,13 @@ bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- AbstractFldInputDlg* pDlg = pFact->CreateFldInputDlg(pParentWin, *this, pFld, bNextButton);
+ boost::scoped_ptr<AbstractFldInputDlg> pDlg(pFact->CreateFldInputDlg(pParentWin, *this, pFld, bNextButton));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if(pWindowState && !pWindowState->isEmpty())
pDlg->SetWindowState(*pWindowState);
// Register for possible input field deletion while dialog is open
- FieldDeletionModify aModify(pDlg);
+ FieldDeletionModify aModify(pDlg.get());
GetDoc()->GetUnoCallBack()->Add(&aModify);
bool bRet = RET_CANCEL == pDlg->Execute();
@@ -209,7 +210,7 @@ bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
if(pWindowState)
*pWindowState = pDlg->GetWindowState();
- delete pDlg;
+ pDlg.reset();
GetWin()->Update();
return bRet;
}
@@ -219,14 +220,14 @@ bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, bool bNextButton, OString* p
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- AbstractDropDownFieldDialog* pDlg = pFact->CreateDropDownFieldDialog(NULL, *this, pFld, bNextButton);
+ boost::scoped_ptr<AbstractDropDownFieldDialog> pDlg(pFact->CreateDropDownFieldDialog(NULL, *this, pFld, bNextButton));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if(pWindowState && !pWindowState->isEmpty())
pDlg->SetWindowState(*pWindowState);
sal_uInt16 nRet = pDlg->Execute();
if(pWindowState)
*pWindowState = pDlg->GetWindowState();
- delete pDlg;
+ pDlg.reset();
bool bRet = RET_CANCEL == nRet;
GetWin()->Update();
if(RET_YES == nRet)