summaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-06-14 17:17:20 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-06-14 17:20:56 +0900
commit57b563273351c5d3eb176ba8768b173853b7e362 (patch)
tree7e5e41861e6a088e60269e6139624968594bb963 /sw
parentfdo#79028: ungroup widgets and Show() them correctly (diff)
downloadcore-57b563273351c5d3eb176ba8768b173853b7e362.tar.gz
core-57b563273351c5d3eb176ba8768b173853b7e362.zip
Avoid possible memory leaks in case of exceptions
Change-Id: I32d1e15cb9f050e3cd05babbd2f21c57f3ccb5e7
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/shells/textsh1.cxx47
-rw-r--r--sw/source/uibase/shells/txtattr.cxx7
-rw-r--r--sw/source/uibase/shells/txtnum.cxx7
-rw-r--r--sw/source/uibase/table/swtablerep.cxx5
-rw-r--r--sw/source/uibase/table/tablemgr.cxx4
5 files changed, 30 insertions, 40 deletions
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 8200cc0630a4..e2144e7fd20d 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -118,6 +118,7 @@
#include <svx/nbdtmgfact.hxx>
#include <svx/nbdtmg.hxx>
#include <numrule.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace svx::sidebar;
@@ -166,13 +167,13 @@ void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const
::PrepareBoxInfo( aCoreSet, rWrtSh );
aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell())));
- SfxAbstractTabDialog* pDlg = NULL;
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
if ( bUseDialog && GetActiveView() )
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- pDlg = pFact->CreateSwCharDlg(rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet, DLG_CHAR_STD);
+ pDlg.reset(pFact->CreateSwCharDlg(rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet, DLG_CHAR_STD));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if( FN_INSERT_HYPERLINK == nSlot )
pDlg->SetCurPageId("hyperlink");
@@ -189,7 +190,7 @@ void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const
const SfxItemSet* pSet = NULL;
if ( !bUseDialog )
pSet = pArgs;
- else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */
+ else if ( pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */
{
pSet = pDlg->GetOutputItemSet();
}
@@ -247,8 +248,6 @@ void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const
rWrtSh.EndAction();
}
}
-
- delete pDlg;
}
static short lcl_AskRedlineMode(Window *pWin)
@@ -303,9 +302,8 @@ void SwTextShell::Execute(SfxRequest &rReq)
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
if (pFact)
{
- VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS );
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS ));
pDlg->Execute();
- delete pDlg;
}
}
else
@@ -450,8 +448,8 @@ void SwTextShell::Execute(SfxRequest &rReq)
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg(
- GetView().GetWindow(), rWrtSh, false);
+ boost::scoped_ptr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg(
+ GetView().GetWindow(), rWrtSh, false));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->SetHelpId(GetStaticInterface()->GetSlot(nSlot)->GetCommand());
if ( pDlg->Execute() == RET_OK )
@@ -466,7 +464,6 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
rReq.Ignore();
- delete pDlg;
}
break;
case FN_FORMAT_FOOTNOTE_DLG:
@@ -474,10 +471,9 @@ void SwTextShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), rWrtSh);
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), rWrtSh));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
break;
}
case SID_INSERTDOC:
@@ -539,7 +535,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- AbstractSwBreakDlg* pDlg = pFact->CreateSwBreakDlg(GetView().GetWindow(), rWrtSh);
+ boost::scoped_ptr<AbstractSwBreakDlg> pDlg(pFact->CreateSwBreakDlg(GetView().GetWindow(), rWrtSh));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if ( pDlg->Execute() == RET_OK )
{
@@ -564,7 +560,6 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
else
rReq.Ignore();
- delete pDlg;
}
switch ( nKind )
@@ -598,10 +593,9 @@ void SwTextShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- VclAbstractDialog* pDlg = pFact->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh, rReq, DLG_INSERT_BOOKMARK );
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh, rReq, DLG_INSERT_BOOKMARK ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
}
break;
@@ -631,7 +625,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- AbstractSwModalRedlineAcceptDlg* pDlg = pFact->CreateSwModalRedlineAcceptDlg(&GetView().GetEditWin());
+ boost::scoped_ptr<AbstractSwModalRedlineAcceptDlg> pDlg(pFact->CreateSwModalRedlineAcceptDlg(&GetView().GetEditWin()));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
switch (lcl_AskRedlineMode(&GetView().GetEditWin()))
@@ -655,7 +649,6 @@ void SwTextShell::Execute(SfxRequest &rReq)
rReq.Done();
break;
}
- delete pDlg;
}
break;
@@ -696,10 +689,10 @@ void SwTextShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh, DLG_SORTING );
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh, DLG_SORTING ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
+ pDlg.reset();
rReq.Done();
}
break;
@@ -708,11 +701,11 @@ void SwTextShell::Execute(SfxRequest &rReq)
SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
- GetView().GetWindow(), &aTmp, rWrtSh);
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ GetView().GetWindow(), &aTmp, rWrtSh));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
+ pDlg.reset();
rReq.Done();
}
break;
@@ -952,7 +945,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
rWrtSh.GetNodeNumStart( pPaM ) );
aCoreSet.Put(aStartAt);
}
- SfxAbstractTabDialog* pDlg = NULL;
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
if ( bUseDialog && GetActiveView() )
{
@@ -963,7 +956,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet, DLG_STD, NULL, false, sDefPage );
+ pDlg.reset(pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet, DLG_STD, NULL, false, sDefPage ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
}
SfxItemSet* pSet = NULL;
@@ -980,7 +973,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
pSet = (SfxItemSet*) pArgs;
}
- else if ( NULL != pDlg && pDlg->Execute() == RET_OK )
+ else if ( pDlg && pDlg->Execute() == RET_OK )
{
// Apply defaults if nessecary.
pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
@@ -1072,8 +1065,6 @@ void SwTextShell::Execute(SfxRequest &rReq)
rWrtSh.EndUndo( UNDO_INSATTR );
}
}
-
- delete pDlg;
}
break;
case FN_NUM_CONTINUE:
diff --git a/sw/source/uibase/shells/txtattr.cxx b/sw/source/uibase/shells/txtattr.cxx
index daa02bb11247..65181a52c21d 100644
--- a/sw/source/uibase/shells/txtattr.cxx
+++ b/sw/source/uibase/shells/txtattr.cxx
@@ -55,6 +55,8 @@
#include <SwStyleNameMapper.hxx>
#include "swabstdlg.hxx"
#include "chrdlg.hrc"
+#include <boost/scoped_ptr.hpp>
+
const sal_uInt32 nFontInc = 40; // 2pt
const sal_uInt32 nFontMaxSz = 19998; // 999.9pt
@@ -438,8 +440,8 @@ void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
- rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS );
+ boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
+ rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if (pDlg->Execute() == RET_OK)
{
@@ -455,7 +457,6 @@ void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
rSh.EndAction();
rReq.Done(*pDlg->GetOutputItemSet());
}
- delete pDlg;
}
}
break;
diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx
index d3da57a3bfdf..b88fd1adea68 100644
--- a/sw/source/uibase/shells/txtnum.cxx
+++ b/sw/source/uibase/shells/txtnum.cxx
@@ -40,6 +40,7 @@
#include <svx/nbdtmgfact.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
+#include <boost/scoped_ptr.hpp>
void SwTextShell::ExecEnterNum(SfxRequest &rReq)
{
@@ -183,8 +184,8 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_SVXTEST_NUM_BULLET,
- GetView().GetWindow(), &aSet, GetShell());
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTabDialog( DLG_SVXTEST_NUM_BULLET,
+ GetView().GetWindow(), &aSet, GetShell()));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
sal_uInt16 nRet = pDlg->Execute();
const SfxPoolItem* pItem;
@@ -226,8 +227,6 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
}
else if ( RET_USER == nRet )
GetShell().DelNumRules();
-
- delete pDlg;
}
break;
diff --git a/sw/source/uibase/table/swtablerep.cxx b/sw/source/uibase/table/swtablerep.cxx
index 5bd4c268651a..fa16f1f439a7 100644
--- a/sw/source/uibase/table/swtablerep.cxx
+++ b/sw/source/uibase/table/swtablerep.cxx
@@ -51,6 +51,7 @@
#include <cmdid.h>
#include <table.hrc>
#include "swtablerep.hxx"
+#include <boost/scoped_array.hpp>
SwTableRep::SwTableRep( const SwTabCols& rTabCol )
:
@@ -110,7 +111,7 @@ bool SwTableRep::FillTabCols( SwTabCols& rTabCols ) const
{
// The invisible separators are taken from the old TabCols,
// the visible coming from pTColumns.
- TColumn* pOldTColumns = new TColumn[nAllCols + 1];
+ boost::scoped_array<TColumn> pOldTColumns(new TColumn[nAllCols + 1]);
SwTwips nStart = 0,
nEnd;
for(i = 0; i < nAllCols - 1; i++)
@@ -156,8 +157,6 @@ bool SwTableRep::FillTabCols( SwTabCols& rTabCols ) const
i++;
}
rTabCols.SetRight(nLeft + nTblWidth);
-
- delete[] pOldTColumns;
}
else
{
diff --git a/sw/source/uibase/table/tablemgr.cxx b/sw/source/uibase/table/tablemgr.cxx
index 8f5ca04fc678..b8d309822879 100644
--- a/sw/source/uibase/table/tablemgr.cxx
+++ b/sw/source/uibase/table/tablemgr.cxx
@@ -44,6 +44,7 @@
#include "docsh.hxx"
#include "unotbl.hxx"
#include "unochart.hxx"
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
@@ -54,10 +55,9 @@ void SwTableFUNC::ColWidthDlg( Window *pParent )
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- VclAbstractDialog* pDlg = pFact->CreateSwTableWidthDlg(pParent, *this);
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwTableWidthDlg(pParent, *this));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
}
// Determine the width