Kaydet (Commit) 8374bbe5 authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid possible memory leaks in case of exceptions

Change-Id: I7878d425cea773338799fb784c25039e6b923e47
üst 7a85ec95
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <svx/itemwin.hxx> #include <svx/itemwin.hxx>
#include <svx/dialmgr.hxx> #include <svx/dialmgr.hxx>
#include "helpid.hrc" #include "helpid.hrc"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util; using namespace ::com::sun::star::util;
...@@ -317,9 +318,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState) ...@@ -317,9 +318,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
} }
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XGradientEntry* pEntry = new XGradientEntry(mpGradientItem->GetGradientValue(), aTmpStr); boost::scoped_ptr<XGradientEntry> pEntry(new XGradientEntry(mpGradientItem->GetGradientValue(), aTmpStr));
XGradientList aGradientList( "", ""/*TODO?*/ ); XGradientList aGradientList( "", ""/*TODO?*/ );
aGradientList.Insert( pEntry ); aGradientList.Insert( pEntry.get() );
aGradientList.SetDirty( false ); aGradientList.SetDirty( false );
const Bitmap aBmp = aGradientList.GetUiBitmap( 0 ); const Bitmap aBmp = aGradientList.GetUiBitmap( 0 );
...@@ -330,7 +331,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState) ...@@ -330,7 +331,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
} }
aGradientList.Remove( 0 ); aGradientList.Remove( 0 );
delete pEntry;
} }
} }
else else
...@@ -363,9 +363,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState) ...@@ -363,9 +363,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
} }
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr); boost::scoped_ptr<XHatchEntry> pEntry(new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr));
XHatchList aHatchList( "", ""/*TODO?*/ ); XHatchList aHatchList( "", ""/*TODO?*/ );
aHatchList.Insert( pEntry ); aHatchList.Insert( pEntry.get() );
aHatchList.SetDirty( false ); aHatchList.SetDirty( false );
const Bitmap aBmp = aHatchList.GetUiBitmap( 0 ); const Bitmap aBmp = aHatchList.GetUiBitmap( 0 );
...@@ -376,7 +376,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState) ...@@ -376,7 +376,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
} }
aHatchList.Remove( 0 ); aHatchList.Remove( 0 );
delete pEntry;
} }
} }
else else
...@@ -409,16 +408,15 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState) ...@@ -409,16 +408,15 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
} }
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XBitmapEntry* pEntry = new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr); boost::scoped_ptr<XBitmapEntry> pEntry(new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr));
XBitmapListRef xBitmapList = XBitmapListRef xBitmapList =
XPropertyList::CreatePropertyList(XBITMAP_LIST, XPropertyList::CreatePropertyList(XBITMAP_LIST,
OUString("TmpList"), ""/*TODO?*/)->AsBitmapList(); OUString("TmpList"), ""/*TODO?*/)->AsBitmapList();
xBitmapList->Insert( pEntry ); xBitmapList->Insert( pEntry.get() );
xBitmapList->SetDirty( false ); xBitmapList->SetDirty( false );
mpFillAttrLB->Fill( xBitmapList ); mpFillAttrLB->Fill( xBitmapList );
mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1); mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
xBitmapList->Remove( 0 ); xBitmapList->Remove( 0 );
delete pEntry;
} }
} }
else else
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "fontworkgallery.hrc" #include "fontworkgallery.hrc"
#include <algorithm> #include <algorithm>
#include <boost/scoped_ptr.hpp>
#include "helpid.hrc" #include "helpid.hrc"
...@@ -202,10 +203,10 @@ void FontWorkGalleryDialog::insertSelectedFontwork() ...@@ -202,10 +203,10 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
if( nItemId > 0 ) if( nItemId > 0 )
{ {
FmFormModel* pModel = new FmFormModel(); boost::scoped_ptr<FmFormModel> pModel(new FmFormModel());
pModel->GetItemPool().FreezeIdRanges(); pModel->GetItemPool().FreezeIdRanges();
if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel ) ) if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel.get() ) )
{ {
SdrPage* pPage = pModel->GetPage(0); SdrPage* pPage = pModel->GetPage(0);
if( pPage && pPage->GetObjCount() ) if( pPage && pPage->GetObjCount() )
...@@ -237,8 +238,6 @@ void FontWorkGalleryDialog::insertSelectedFontwork() ...@@ -237,8 +238,6 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
} }
} }
} }
delete pModel;
} }
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <svx/itemwin.hxx> #include <svx/itemwin.hxx>
#include <svx/dialmgr.hxx> #include <svx/dialmgr.hxx>
#include <svx/unoapi.hxx> #include <svx/unoapi.hxx>
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
...@@ -356,27 +357,27 @@ SvxLineEndWindow::~SvxLineEndWindow() ...@@ -356,27 +357,27 @@ SvxLineEndWindow::~SvxLineEndWindow()
IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl) IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl)
{ {
XLineEndItem* pLineEndItem = NULL; boost::scoped_ptr<XLineEndItem> pLineEndItem;
XLineStartItem* pLineStartItem = NULL; boost::scoped_ptr<XLineStartItem> pLineStartItem;
sal_uInt16 nId = aLineEndSet.GetSelectItemId(); sal_uInt16 nId = aLineEndSet.GetSelectItemId();
if( nId == 1 ) if( nId == 1 )
{ {
pLineStartItem = new XLineStartItem(); pLineStartItem.reset(new XLineStartItem());
} }
else if( nId == 2 ) else if( nId == 2 )
{ {
pLineEndItem = new XLineEndItem(); pLineEndItem.reset(new XLineEndItem());
} }
else if( nId % 2 ) // beginning of line else if( nId % 2 ) // beginning of line
{ {
XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 ); XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 );
pLineStartItem = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ); pLineStartItem.reset(new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ));
} }
else // end of line else // end of line
{ {
XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 ); XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 );
pLineEndItem = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ); pLineEndItem.reset(new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ));
} }
if ( IsInPopupMode() ) if ( IsInPopupMode() )
...@@ -407,9 +408,6 @@ IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl) ...@@ -407,9 +408,6 @@ IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl)
OUString( ".uno:LineEndStyle" ), OUString( ".uno:LineEndStyle" ),
aArgs ); aArgs );
delete pLineEndItem;
delete pLineStartItem;
return 0; return 0;
} }
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
#include <svx/svdoutl.hxx> #include <svx/svdoutl.hxx>
#include <editeng/flditem.hxx> #include <editeng/flditem.hxx>
#include "boost/scoped_ptr.hpp" #include <boost/scoped_ptr.hpp>
#include <UnoGraphicExporter.hxx> #include <UnoGraphicExporter.hxx>
...@@ -439,7 +439,7 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid ...@@ -439,7 +439,7 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid
if(bSuccess) if(bSuccess)
{ {
SdrView* pView = new SdrView(mpDoc, pVDev); boost::scoped_ptr<SdrView> pView(new SdrView(mpDoc, pVDev));
pView->SetPageVisible( false ); pView->SetPageVisible( false );
pView->SetBordVisible( false ); pView->SetBordVisible( false );
pView->SetGridVisible( false ); pView->SetGridVisible( false );
...@@ -451,7 +451,6 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid ...@@ -451,7 +451,6 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid
ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage ); ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
pView->CompleteRedraw(pVDev, aRegion, &aRedirector); pView->CompleteRedraw(pVDev, aRegion, &aRedirector);
delete pView;
} }
else else
{ {
...@@ -713,14 +712,13 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, ...@@ -713,14 +712,13 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
} }
VirtualDevice* pVDev = CreatePageVDev( pPage, nWidthPix, nHeightPix ); boost::scoped_ptr<VirtualDevice> pVDev(CreatePageVDev( pPage, nWidthPix, nHeightPix ));
if( pVDev ) if( pVDev )
{ {
aGraphic = pVDev->GetBitmap( Point(), pVDev->GetOutputSize() ); aGraphic = pVDev->GetBitmap( Point(), pVDev->GetOutputSize() );
aGraphic.SetPrefMapMode( aMap ); aGraphic.SetPrefMapMode( aMap );
aGraphic.SetPrefSize( aSize ); aGraphic.SetPrefSize( aSize );
delete pVDev;
} }
} }
// create a metafile to export a vector format // create a metafile to export a vector format
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include "svx/unoapi.hxx" #include "svx/unoapi.hxx"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::rtl; using namespace ::rtl;
...@@ -87,11 +88,10 @@ void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, cons ...@@ -87,11 +88,10 @@ void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, cons
SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, mnWhich, mnWhich ); SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, mnWhich, mnWhich );
maItemSetVector.push_back( mpInSet ); maItemSetVector.push_back( mpInSet );
NameOrIndex* pNewItem = createItem(); boost::scoped_ptr<NameOrIndex> pNewItem(createItem());
pNewItem->SetName( aName ); pNewItem->SetName( aName );
pNewItem->PutValue( aElement, mnMemberId ); pNewItem->PutValue( aElement, mnMemberId );
mpInSet->Put( *pNewItem, mnWhich ); mpInSet->Put( *pNewItem, mnWhich );
delete pNewItem;
} }
// XNameContainer // XNameContainer
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#include "svx/extrud3d.hxx" #include "svx/extrud3d.hxx"
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/scoped_ptr.hpp>
#include <vcl/wmf.hxx> #include <vcl/wmf.hxx>
using namespace ::osl; using namespace ::osl;
...@@ -685,7 +686,7 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const ...@@ -685,7 +686,7 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
SdrModel* pModel = mpObj->GetModel(); SdrModel* pModel = mpObj->GetModel();
SdrPage* pPage = mpObj->GetPage(); SdrPage* pPage = mpObj->GetPage();
E3dView* pView = new E3dView( pModel, &aVDev ); boost::scoped_ptr<E3dView> pView(new E3dView( pModel, &aVDev ));
pView->hideMarkHandles(); pView->hideMarkHandles();
SdrPageView* pPageView = pView->ShowSdrPage(pPage); SdrPageView* pPageView = pView->ShowSdrPage(pPage);
...@@ -717,7 +718,6 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const ...@@ -717,7 +718,6 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
} }
pView->UnmarkAll(); pView->UnmarkAll();
delete pView;
return aAny; return aAny;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment