summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-05-19 22:25:31 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-05-19 22:28:31 +0900
commit018e2f629e125f1a0fe33471a0e4fe606813aa91 (patch)
tree68e8420ba62a0cb41b32edc766943d9c9249715d /sd
parentb1aa528721c578767985a1b31f653375f26db076 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I61fe5f5fff157531de9962a2dd4e6e0431e8601c
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/html/HtmlOptionsDialog.cxx5
-rw-r--r--sd/source/ui/animations/CustomAnimationPane.cxx9
-rw-r--r--sd/source/ui/dlg/sdpreslt.cxx8
-rw-r--r--sd/source/ui/docshell/docshel3.cxx4
-rw-r--r--sd/source/ui/func/fuarea.cxx7
-rw-r--r--sd/source/ui/func/fubullet.cxx7
-rw-r--r--sd/source/ui/func/fuchar.cxx5
-rw-r--r--sd/source/ui/func/fucopy.cxx14
-rw-r--r--sd/source/ui/func/fucushow.cxx5
-rw-r--r--sd/source/ui/func/fuinsert.cxx10
10 files changed, 34 insertions, 40 deletions
diff --git a/sd/source/filter/html/HtmlOptionsDialog.cxx b/sd/source/filter/html/HtmlOptionsDialog.cxx
index d9ecbafd2eea..feb9ca4bbdcb 100644
--- a/sd/source/filter/html/HtmlOptionsDialog.cxx
+++ b/sd/source/filter/html/HtmlOptionsDialog.cxx
@@ -46,6 +46,8 @@ using namespace com::sun::star::ui::dialogs;
#include "pres.hxx"
#include "sdabstdlg.hxx"
+#include <boost/scoped_ptr.hpp>
+
class SdHtmlOptionsDialog : public cppu::WeakImplHelper5
<
XExporter,
@@ -221,7 +223,7 @@ sal_Int16 SdHtmlOptionsDialog::execute()
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
if( pFact )
{
- AbstractSdPublishingDlg* pDlg = pFact->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType );
+ boost::scoped_ptr<AbstractSdPublishingDlg> pDlg(pFact->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType ));
if( pDlg )
{
if( pDlg->Execute() )
@@ -233,7 +235,6 @@ sal_Int16 SdHtmlOptionsDialog::execute()
{
nRet = ExecutableDialogResults::CANCEL;
}
- delete pDlg;
}
}
return nRet;
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index 457e2de93c5c..8ccd1176f812 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -82,6 +82,7 @@
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/range/b2drange.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::animations;
@@ -1562,15 +1563,13 @@ void CustomAnimationPane::showOptions(const OString& sPage)
{
STLPropertySet* pSet = createSelectionSet();
- CustomAnimationDialog* pDlg = new CustomAnimationDialog(this, pSet, sPage);
+ boost::scoped_ptr<CustomAnimationDialog> pDlg(new CustomAnimationDialog(this, pSet, sPage));
if( pDlg->Execute() )
{
addUndo();
changeSelection( pDlg->getResultSet(), pSet );
updateControls();
}
-
- delete pDlg;
}
void CustomAnimationPane::onChangeCurrentPage()
@@ -1743,7 +1742,7 @@ void CustomAnimationPane::onChange( bool bCreate )
}
}
- CustomAnimationCreateDialog* pDlg = new CustomAnimationCreateDialog( this, this, aTargets, bHasText, sPresetId, fDuration );
+ boost::scoped_ptr<CustomAnimationCreateDialog> pDlg(new CustomAnimationCreateDialog( this, this, aTargets, bHasText, sPresetId, fDuration ));
if( pDlg->Execute() )
{
addUndo();
@@ -1812,7 +1811,7 @@ void CustomAnimationPane::onChange( bool bCreate )
mrBase.GetDocShell()->SetModified();
}
- delete pDlg;
+ pDlg.reset();
updateControls();
diff --git a/sd/source/ui/dlg/sdpreslt.cxx b/sd/source/ui/dlg/sdpreslt.cxx
index b9349e0b0162..2ddf8e05841c 100644
--- a/sd/source/ui/dlg/sdpreslt.cxx
+++ b/sd/source/ui/dlg/sdpreslt.cxx
@@ -29,6 +29,7 @@
#include "drawdoc.hxx"
#include "sdpage.hxx"
#include "DrawDocShell.hxx"
+#include <boost/scoped_ptr.hpp>
SdPresLayoutDlg::SdPresLayoutDlg(::sd::DrawDocShell* pDocShell,
@@ -171,14 +172,11 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLayoutHdl)
*/
IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl)
{
- SfxNewFileDialog* pDlg = new SfxNewFileDialog(this, SFXWB_PREVIEW);
+ boost::scoped_ptr<SfxNewFileDialog> pDlg(new SfxNewFileDialog(this, SFXWB_PREVIEW));
pDlg->SetText(SD_RESSTR(STR_LOAD_PRESENTATION_LAYOUT));
if(!IsReallyVisible())
- {
- delete pDlg;
return 0;
- }
sal_uInt16 nResult = pDlg->Execute();
// Inserted update to force repaint
@@ -205,7 +203,7 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl)
default:
bCancel = true;
}
- delete pDlg;
+ pDlg.reset();
if( !bCancel )
{
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx
index a687dca9b83c..a4b044f54d04 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -56,6 +56,7 @@
#include "View.hxx"
#include "slideshow.hxx"
#include "fuhhconv.hxx"
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
@@ -283,9 +284,8 @@ void DrawDocShell::Execute( SfxRequest& rReq )
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
if (pFact && mpViewShell)
{
- VclAbstractDialog* pDlg = pFact->CreateVclDialog( mpViewShell->GetActiveWindow(), SID_LANGUAGE_OPTIONS );
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( mpViewShell->GetActiveWindow(), SID_LANGUAGE_OPTIONS ));
pDlg->Execute();
- delete pDlg;
}
}
else
diff --git a/sd/source/ui/func/fuarea.cxx b/sd/source/ui/func/fuarea.cxx
index 2e941ec42017..a6da6484bcb8 100644
--- a/sd/source/ui/func/fuarea.cxx
+++ b/sd/source/ui/func/fuarea.cxx
@@ -34,6 +34,7 @@
#include "app.hrc"
#include <svx/svxdlg.hxx>
#include <svx/dialogs.hrc>
+#include <boost/scoped_ptr.hpp>
namespace sd {
TYPEINIT1( FuArea, FuPoor );
@@ -61,10 +62,10 @@ void FuArea::DoExecute( SfxRequest& rReq )
mpView->GetAttributes( aNewAttr );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- AbstractSvxAreaTabDialog * pDlg = pFact ? pFact->CreateSvxAreaTabDialog( NULL,
+ boost::scoped_ptr<AbstractSvxAreaTabDialog> pDlg(pFact ? pFact->CreateSvxAreaTabDialog( NULL,
&aNewAttr,
mpDoc,
- true) : 0;
+ true) : 0);
if( pDlg && (pDlg->Execute() == RET_OK) )
{
mpView->SetAttributes (*(pDlg->GetOutputItemSet ()));
@@ -82,8 +83,6 @@ void FuArea::DoExecute( SfxRequest& rReq )
0 };
mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
-
- delete pDlg;
}
rReq.Ignore ();
diff --git a/sd/source/ui/func/fubullet.cxx b/sd/source/ui/func/fubullet.cxx
index 95e9e913a459..d2359f9952f1 100644
--- a/sd/source/ui/func/fubullet.cxx
+++ b/sd/source/ui/func/fubullet.cxx
@@ -38,6 +38,7 @@
#include <svx/svxdlg.hxx>
#include <svx/dialogs.hrc>
#include "drawview.hxx"
+#include <boost/scoped_ptr.hpp>
#include "app.hrc"
@@ -190,9 +191,9 @@ void FuBullet::InsertSpecialCharacter( SfxRequest& rReq )
aSet.Put( *pFontItem );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- SfxAbstractDialog* pDlg = pFact ? pFact->CreateSfxDialog( &mpView->GetViewShell()->GetViewFrame()->GetWindow(), aSet,
+ boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact ? pFact->CreateSfxDialog( &mpView->GetViewShell()->GetViewFrame()->GetWindow(), aSet,
mpView->GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(),
- RID_SVXDLG_CHARMAP ) : 0;
+ RID_SVXDLG_CHARMAP ) : 0);
if( !pDlg )
return;
@@ -215,8 +216,6 @@ void FuBullet::InsertSpecialCharacter( SfxRequest& rReq )
if ( pCItem )
aChars = pCItem->GetValue();
}
-
- delete( pDlg );
}
if (!aChars.isEmpty())
diff --git a/sd/source/ui/func/fuchar.cxx b/sd/source/ui/func/fuchar.cxx
index d9549b1e7dd2..0c42a4f4cdd4 100644
--- a/sd/source/ui/func/fuchar.cxx
+++ b/sd/source/ui/func/fuchar.cxx
@@ -34,6 +34,7 @@
#include "ViewShell.hxx"
#include "DrawDocShell.hxx"
#include "sdabstdlg.hxx"
+#include <boost/scoped_ptr.hpp>
namespace sd {
@@ -71,7 +72,7 @@ void FuChar::DoExecute( SfxRequest& rReq )
aNewAttr.Put( aEditAttr, false );
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
- SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdTabCharDialog( NULL, &aNewAttr, mpDoc->GetDocSh() ) : 0;
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdTabCharDialog( NULL, &aNewAttr, mpDoc->GetDocSh() ) : 0);
sal_uInt16 nResult = RET_CANCEL;
if( pDlg )
{
@@ -87,8 +88,6 @@ void FuChar::DoExecute( SfxRequest& rReq )
rReq.Done( *( pDlg->GetOutputItemSet() ) );
pArgs = rReq.GetArgs();
}
-
- delete pDlg;
}
if( nResult != RET_OK )
{
diff --git a/sd/source/ui/func/fucopy.cxx b/sd/source/ui/func/fucopy.cxx
index 02d194f33a9e..9cbcc06c4fa0 100644
--- a/sd/source/ui/func/fucopy.cxx
+++ b/sd/source/ui/func/fucopy.cxx
@@ -38,6 +38,8 @@
#include <svx/xfillit0.hxx>
#include <sfx2/request.hxx>
#include "sdabstdlg.hxx"
+#include <boost/scoped_ptr.hpp>
+
namespace sd {
TYPEINIT1( FuCopy, FuPoor );
@@ -99,7 +101,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
if( pFact )
{
- AbstractCopyDlg* pDlg = pFact->CreateCopyDlg(NULL, aSet, mpDoc->GetColorList(), mpView );
+ boost::scoped_ptr<AbstractCopyDlg> pDlg(pFact->CreateCopyDlg(NULL, aSet, mpDoc->GetColorList(), mpView ));
if (!pDlg)
return;
@@ -115,12 +117,11 @@ void FuCopy::DoExecute( SfxRequest& rReq )
default:
{
- delete pDlg;
+ pDlg.reset();
mpView->EndUndo();
}
return; // Cancel
}
- delete pDlg;
}
}
@@ -167,7 +168,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
// remove handles
//HMHmpView->HideMarkHdl();
- SfxProgress* pProgress = NULL;
+ boost::scoped_ptr<SfxProgress> pProgress;
bool bWaiting = false;
if( nNumber > 1 )
@@ -175,7 +176,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
OUString aStr( SD_RESSTR( STR_OBJECTS ) );
aStr += " " + SD_RESSTR( STR_UNDO_COPYOBJECTS );
- pProgress = new SfxProgress( mpDocSh, aStr, nNumber );
+ pProgress.reset(new SfxProgress( mpDocSh, aStr, nNumber ));
mpDocSh->SetWaitCursor( true );
bWaiting = true;
}
@@ -277,8 +278,7 @@ void FuCopy::DoExecute( SfxRequest& rReq )
}
}
- if ( pProgress )
- delete pProgress;
+ pProgress.reset();
if ( bWaiting )
mpDocSh->SetWaitCursor( false );
diff --git a/sd/source/ui/func/fucushow.cxx b/sd/source/ui/func/fucushow.cxx
index ab1ccd41af32..514520beaf76 100644
--- a/sd/source/ui/func/fucushow.cxx
+++ b/sd/source/ui/func/fucushow.cxx
@@ -32,6 +32,7 @@
#include <sfx2/viewfrm.hxx>
#include "sdabstdlg.hxx"
+#include <boost/scoped_ptr.hpp>
namespace sd {
@@ -59,7 +60,7 @@ rtl::Reference<FuPoor> FuCustomShowDlg::Create( ViewShell* pViewSh, ::sd::Window
void FuCustomShowDlg::DoExecute( SfxRequest& )
{
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
- AbstractSdCustomShowDlg* pDlg = pFact ? pFact->CreateSdCustomShowDlg( NULL, *mpDoc ) : 0;
+ boost::scoped_ptr<AbstractSdCustomShowDlg> pDlg(pFact ? pFact->CreateSdCustomShowDlg( NULL, *mpDoc ) : 0);
if( pDlg )
{
sal_uInt16 nRet = pDlg->Execute();
@@ -69,7 +70,7 @@ void FuCustomShowDlg::DoExecute( SfxRequest& )
sd::PresentationSettings& rSettings = mpDoc->getPresentationSettings();
rSettings.mbCustomShow = pDlg->IsCustomShow();
}
- delete pDlg;
+ pDlg.reset();
if( nRet == RET_YES )
{
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index cb6c62be2c96..88eb7af439e2 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -81,6 +81,7 @@
#include "sdxfer.hxx"
#include <vcl/svapp.hxx>
#include "undo/undoobjects.hxx"
+#include <boost/scoped_ptr.hpp>
#include "glob.hrc"
using namespace com::sun::star;
@@ -200,7 +201,7 @@ void FuInsertClipboard::DoExecute( SfxRequest& )
sal_uLong nFormatId;
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( mpViewShell->GetActiveWindow() );
+ boost::scoped_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( mpViewShell->GetActiveWindow() ));
if ( pDlg )
{
::com::sun::star::datatransfer::DataFlavor aFlavor;
@@ -242,8 +243,6 @@ void FuInsertClipboard::DoExecute( SfxRequest& )
}
}
}
-
- delete pDlg;
}
}
@@ -450,9 +449,9 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
case SID_INSERT_FLOATINGFRAME :
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- SfxAbstractInsertObjectDialog* pDlg =
+ boost::scoped_ptr<SfxAbstractInsertObjectDialog> pDlg(
pFact->CreateInsertObjectDialog( mpViewShell->GetActiveWindow(), SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommandString(),
- xStorage, &aServerLst );
+ xStorage, &aServerLst ));
if ( pDlg )
{
pDlg->Execute();
@@ -465,7 +464,6 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
if ( xObj.is() )
mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
- DELETEZ( pDlg );
}
break;