[Libreoffice-commits] core.git: sd/source

Takeshi Abe tabe at fixedpoint.jp
Mon May 19 06:31:34 PDT 2014


 sd/source/filter/html/HtmlOptionsDialog.cxx     |    5 +++--
 sd/source/ui/animations/CustomAnimationPane.cxx |    9 ++++-----
 sd/source/ui/dlg/sdpreslt.cxx                   |    8 +++-----
 sd/source/ui/docshell/docshel3.cxx              |    4 ++--
 sd/source/ui/func/fuarea.cxx                    |    7 +++----
 sd/source/ui/func/fubullet.cxx                  |    7 +++----
 sd/source/ui/func/fuchar.cxx                    |    5 ++---
 sd/source/ui/func/fucopy.cxx                    |   14 +++++++-------
 sd/source/ui/func/fucushow.cxx                  |    5 +++--
 sd/source/ui/func/fuinsert.cxx                  |   10 ++++------
 10 files changed, 34 insertions(+), 40 deletions(-)

New commits:
commit 018e2f629e125f1a0fe33471a0e4fe606813aa91
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon May 19 22:25:31 2014 +0900

    Avoid possible memory leaks in case of exceptions
    
    Change-Id: I61fe5f5fff157531de9962a2dd4e6e0431e8601c

diff --git a/sd/source/filter/html/HtmlOptionsDialog.cxx b/sd/source/filter/html/HtmlOptionsDialog.cxx
index d9ecbaf..feb9ca4 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 457e2de..8ccd117 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 b9349e0..2ddf8e0 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 a687dca..a4b044f 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 2e941ec..a6da648 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 95e9e91..d2359f9 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 d9549b1..0c42a4f 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 02d194f..9cbcc06 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 ab1ccd4..514520b 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 cb6c62b..88eb7af 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;


More information about the Libreoffice-commits mailing list